Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Question 8 - OOP TicTacToe is played on a 3x3 board. We need to build a class that represents a TicTacToe game. A TicTacToe
Java
Question 8 - OOP TicTacToe is played on a 3x3 board. We need to build a class that represents a TicTacToe game. A TicTacToe board can be represented as a 2D Array of chaters. A TicTacToe object must track of the next move (character 'X'orO) (a) Complete the following TicTacToe class template. public class TicTacToe / define all instance variables here / define a default constructor that initializes each cel1 to character '* public TicTacToe O / checks if a nove to cell (i.j) is a valid move. A valid move is a move where indices i and j air the cell (i.j) is not the character ' public boolean validMove(int i, int j) /makes the move vhere ch is placed in cel1 (i.j)/ public void makeMove(int i, int j, char ch) / TicTacToe players alternate turns. Return the char (X or 0) representing the next move public char nextMove returns true if the game is over. Game is over, if all cells are full and no winners or the winner has 3 of the same character (X or O) in a row, column, or diagonally (there are two d public boolean gameOver ) /returns the String that representa the TicTacToe board as a 3x3 grid public String toString) vi (b) write a main method to test your TicTacToe class. (c) list some test cases for each of the methods in the classStep 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