Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The code and the output Console Shell Instructions 1. Create a TicTacToe class 2. Declare 2D array as an instance variable representing the grid and
The code and the output
Console Shell Instructions 1. Create a TicTacToe class 2. Declare 2D array as an instance variable representing the grid and a integer instance variable to represent who's turn it is. 3. Create a constructor that initializes the 2D array with the "-" value for all the items in the array. Also initialize the turn variable. 4. Create a print() method to print all the items in the 2D array separated by a space. 5. In Main, create a TicTacToe object and call print you can see the grid with all "-". 6. Ask for first player's name and second player's name and store those values Part 2: Methods 1. checkLocation(int row, int col) - This method returns a boolean value that determines if the spot a user picks to put their piece is valid. A valid space is one where the row and column are within the size of the board, and there are no X or O values currently present. take screenshot demonstrating that the method works and post on canvas 2. take Turn(int row, int col) - This method adds an X or O to the array at position row,col depending on whose turn it is. If it's an even turn, X should be added to the array, if it's odd, O should be added. It also adds one to the value of turn. take screenshot demonstrating that the method works and post on canvas 3. checkWin(String xo) - This method returns a boolean that determines if a user has won the game. This method uses three methods to make that check: . checkCol(String xo) This checks if a player has three X or O values in a single column, and returns true if that's the case. - checkRow(String xo) This checks if a player has three X or O values in a single row. checkDiag(String xo) - This checks if a player has three X or O values diagonally. checkWin(String xo) only returns true if one of these three checks is true. take screenshot demonstrating that the method works and post on canvas Part 3: Game Play Complete game play in Main.java ask user for row and col. only continue if given acceptable values. place X or O accordingly and check for a winner. player 2 should not get a turn if the game is won by player 1 Screenshot player 1 winning, player 2 winning, and a tie.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started