Write a class to handle the basics of a two-player game of
Tic-Tac-Toe. The required methods are below. If you've done things
correctly, save a copy of the files provided below into the same folder
TicTacToeClass.java and compile and run them to play or
test your game.
The only tricky part about the game is determining if a given person has won. The more straightforward way to do it takes 8 if statements.
|a two-dimensional array of chars|
|an integer keeping track of the number of turns played this game|
|the default constructor, which just
creates the two-dimensional array and fills each slot with
|returns the numbers of turns played so far|
|returns the character
representing the piece at the given location. Should return either
|displays the current board on the screen|
|allows the given player to place their move at the given row and column. The row and column numbers are 0-based, so valid numbers are 0, 1, or 2|
(...a game already in progress) X O O X X X O 'O', choose your location (row, column): 0 1 X O O O X X X O 'X', choose your location (row, column): 2 0 X O O O X X X X O The game is a tie.
©2013 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.