This is an unfinished game of TicTacToe to help learn Java. Make a copy, then finish the abstract methods in FinishedBoard.java (setBoard, isMovelegal, and checkWin). Message me for help with solutions. Good luck!
- In replit.com, go to the main menu and click
Create Repl
- Select
Import from Github
- Paste https://github.com/Angelbots1339/Angelbotics-TicTacToe-Practice into the URL and click
Import
- Your files are found in the
srcfolder
- Finish the 3 empty methods in
FinishedBoard.java
GameBoard.java is an abstract class for you to finish in your own copy. There are several member objects you will need to use:
boolean player1Turn: A boolean, used to indicate which player's turn it is(True if player 1, false if player 2). This will update automatically once a player makes a moveint[][] board: A two dimensional integer array containing the current board. Access at position x and y by usingboard[x][y]. A new game looks like:
[0] [0] [0]
[0] [0] [0]
[0] [0] [0]
, where 0 siginifes a blank space, 1 signifies a player one move, and 2 signifies a player two move
player1Turn and board are avalible fo you to use in your methods.
Should set the board coordinate at (x,y) to the current player (use player1Turn). Return true.
Should check if a move is legal (think about error bounds & if space is already occupied)
Checks who has won the game. Return 1 if player one wins, 2 if player 2 wins, 0 if there is a tie (no open spaces left), and -1 if the game is not yet over. There are multiple correct ways of finishing this method, however some are less time consuming but more difficult. A hint is to write out all possible conditions in english before you write the code. COMMENT YOUR CODE!!! If it takes more than one session to finish this method, the easiest way to pick it back up is to read your own comments. Also, it will be easier for others to help you if they can understand what your code is supposed to be doing.