Question
Hello I need some help writing this C++ code. The program is a tic tac toe program. Write a program that allows two players (X
Hello I need some help writing this C++ code.
The program is a tic tac toe program. 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 ticTacToe 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. Pseudo code is done. I could use some help filling it in c++.
#include
using namespace std;
enum status {win, draw, continue};
class ticTacToe {
public:
void play(); //function to start to play game
void displayBoard() const; // function to print board
boolisValidMove(int x, int y) const; //function to determine if a move is valid
bool getXOmove (char moveSymbol); //Function to get a move for a player
status gameStatus(); //Function to determine the current status for the game
void reStart(); //Function to restart the game.
ticTacToe(); //Default constructor //Postcondition: Initializes the board to an empty state
private: char board[3][3]; int noOfMoves;
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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