Question: So ive recently completed a functional tik tak toe program and am now trying to rearange it to a class / object structure. As well

So ive recently completed a functional tik tak toe program and am now trying to rearange it to a class/object structure. As well the constructor TicTacToe::TicTacToe() should initialize the class attributes (sigil, and board). Theres no need to chance the functions unless necessary.
As well the class interface should consist of
class TicTacToe {
public:
TicTacToe();
// void play();
private:
// Hint: Initialize these attributes in the constructor.
char sigil[3];
int board[3][3];
// void drawBoard();
// bool isMoveLegal(int row, int column);
// int winner();
// bool isGameOver();
};
And the main should look like
int main(){
TicTacToe Game;
// Game.play();
return 0;
below is the program at hand
const char SIGIL[3]={'.','X','O'};
// Function Prototypes.
void drawBoard(int board[3][3]);
bool isMoveLegal(int board[3][3], int row, int column);
int winner(int board[3][3]);
bool isGameOver(int board[3][3]);
void drawBoard(int board[3][3])
{
cout <<"012"<< endl;
for(int i =0; i <3; i++)
{
cout << i <<"";
for(int j =0; j <3; j++)
{
if(board[i][j]==0)
{
cout <<".";
}
else if(board[i][j]==1)
{
cout <<"X ";
}
else if(board[i][j]==2)
{
cout <<"0";
}
}
cout << endl;
}
}
bool isMoveLegal(int board[3][3], int row, int column)
{
if(row <0|| row >=3|| column <0|| column >=3|| board[row][column]!=0)
{
return false;
}
return true;
}
int winner(int board[3][3])
{
for(int i =0; i <3; ++i)
{
// Check rows/columns
if(board[i][0]== board[i][1] && board[i][1]== board[i][2] && board[i][0]!=0)
return board[i][0];
if(board[0][i]== board[1][i] && board[1][i]== board[2][i] && board[0][i]!=0)
return board[0][i];
}
// Check diagonal
if(board[0][0]== board[1][1] && board[1][1]== board[2][2] && board[0][0]!=0)
return board[0][0];
if(board[0][2]== board[1][1] && board[1][1]== board[2][0] && board[0][2]!=0)
return board[0][2];
return 0;
}
bool isGameOver(int board[3][3]){
if (winner(board)==1|| winner(board)==2)
return true;
for (int r =0; r <=2; r++)
for (int c =0; c <=2; c++)
if (board[r][c]==0)
return false;
return true;
}
int main(){
int board[3][3];
for (int i =0; i <3; ++i){
for (int j =0; j <3; ++j){
board[i][j]=0;
}
}
int player =1;
int row, column, result;
bool legalMove;
// Start game.
drawBoard(board);
while (!isGameOver(board)){

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 Programming Questions!