Tic Tac Toe on Java GUI 2 human players THREE SEPERATE CLASSES Game Main class This class
Question:
Tic Tac Toe on Java GUI
2 human players
THREE SEPERATE CLASSES
Game Main class
This class contains the main method and handles the gameplay. The class GameMain controls the logical flow of the game, which will handle moving between the player turns and updating the game state. It declares the constants that specify how many cells are on the board and the dimensions for most of the drawn elements in the game (canvas, cell, symbol size and stroke width). The constructor sets up the Mouse Listener to listen for the Mouse Click events, sets up the status label that will show who’s turn it is and whether a player has won or drawn, creates a new Board object and calls the method to initialise the game board content. The GameMain class supports operations of the overall gameplay with UpdateGame().
Board Class
Board is the class that models the Tic-Tac-Toe game board. The constructor initialises the Cell array that will hold the Cell positions and then creates a new Cell object to store in each of the positions in the array. isDraw() and hasWon()methods are used to update the Game Status (GameState.'player'_won, GameState.draw). The paint()method handles drawing the Board grid and calls the cell.paint()method so Cells are drawn.
Cell Class
The Cell class models each individual cell of the game board. Cell has an instance variable called content (with package access), of the type enum Player. You can only assign a value from the enum constants into the Cell content. The constant assigned to the Cell, if it is a Nought or a Cross, is drawn in its paint() method (which gets called by the Board class). A Cell also has an operation called clear()