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 classobject 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;
int board;
void drawBoard;
bool isMoveLegalint row, int column;
int winner;
bool isGameOver;
;
And the main should look like
int main
TicTacToe Game;
Game.play;
return ;
below is the program at hand
const char SIGILXO;
Function Prototypes.
void drawBoardint board;
bool isMoveLegalint board int row, int column;
int winnerint board;
bool isGameOverint board;
void drawBoardint board
cout endl;
forint i ; i ; i
cout i ;
forint j ; j ; j
ifboardij
cout ;
else ifboardij
cout X ;
else ifboardij
cout ;
cout endl;
bool isMoveLegalint board int row, int column
ifrow row column column boardrowcolumn
return false;
return true;
int winnerint board
forint i ; i ; i
Check rowscolumns
ifboardi boardi && boardi boardi && boardi
return boardi;
ifboardi boardi && boardi boardi && boardi
return boardi;
Check diagonal
ifboard board && board board && board
return board;
ifboard board && board board && board
return board;
return ;
bool isGameOverint board
if winnerboard winnerboard
return true;
for int r ; r ; r
for int c ; c ; c
if boardrc
return false;
return true;
int main
int board;
for int i ; i ; i
for int j ; j ; j
boardij;
int player ;
int row, column, result;
bool legalMove;
Start game.
drawBoardboard;
while isGameOverboard
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
