Question: This is for Java. 1. (15 pts) Tic-tac-toe. Write a game of tic-tac-toe in a class called TicTacToe. An object of type TicTacToe is a

This is for Java.

1. (15 pts) Tic-tac-toe. Write a game of tic-tac-toe in a class called TicTacToe. An object of type TicTacToe is a single game. Store the game board as a single 2-D array (3x3) of base type char. Use good data encapsulation practices and provide a public interface for methods that:

a. add a move

b. display the board

c. determine whose turn it is (X or O)

d. determine if there is a winner e. say who the winner is

f. reinitialize the game to the beginning

Write a main method for the class that will allow 2 players to enter moves in turn at the same keyboard. Allow the players to play multiple games. Be sure to test each method individually as you go, and avoid duplicate code. For full credit, include error checking to ensure a move is within the array bounds and not already played. Also be sure to end the game if it is a draw (this can be done by writing a method to check for a draw or by counting moves).

Here is an example of what the first move might look like:

Enter the row (1-3) for X:

Enter the row (1-3) for X: 1

Enter the column (1-3) for X: 3

| | X ----------- | | ----------- | |

Enter the row (1-3) for O:

...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!