Question: C++ please Write a program that allows two players (X and O) to play the tic-tac-toe game on a 3 by 3 two-dimensional array board.

C++ please

C++ please Write a program that allows two players (X and O)

Write a program that allows two players (X and O) to play the tic-tac-toe game on a 3 by 3 two-dimensional array board. Some of the operations on a ticTac Toe object are printing the current board, getting a move, checking if a move is valid and determining the winner after each move. Add additional operations as needed. You are giving the Tic Tac Toe.h header file with the tic Tac Toe class as follows: Tic Tac Toe.h header file Sample Output 1 2 3 Player O enter move (row col): 22 Player O enter move (row col): 31 1 2 3 1 1 1 Player O enter move (row col): 23 1 2 3 #include 1 x L using namespace std; enum status {WIN, DRAW, CONTINUE}; 1 x 0x 2 --- 3 1 - O 2 xi oi o class tictactoe 3 0 1 Player X enter move (row col): 11 1 2 3 1 x 1 3 0 1 public: void play(); //Function to start the play. x Player X enter move (row col): 13 1 2 3 Player X enter move (row col): 33 x 1 2 3 void displayBoard() const; //Function to print the board. 2 1 x --- 2 x 01 3 0 1 x 0x bool isValidMove(int x, int y) const; //Function to determine if a move is valid. 2 X! O! bool getxoMove(char moveSymbol); //Function to get a move for a player Player O enter move (row col): 2 2 1 2 3 Player O enter move (row col): 12 30 x x 3 1 X 1 This game is a draw! status gameStatus(); //Function to determine the current status of the game. _1- 1 2 1 X 0 - - 2 XL 01 X void restart(); //Function to restart the game. 2 - 3 1 0 1 -_ 3 0 1 ticTacToe(); //Default constructor. //Postcondition: Initializes the board to an empty state. Player X enter move (row col): 21 1 2 3 Player X enter move (row col): 32 1 2 3 1 x L private: char board[3][3]; int noOfMoves; 1 XT OLX -L- 2 X 0 -44 2 x 0 3 1

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!