This class can managed a Tic-Tac-Toe game. The class allows basic operations like initializing the game, placing marks according to the rules, checking if the game is over, undo a move etc ... More...
#include <tictactoe.h>
Public Member Functions | |
| TicTacToe (void) | |
| Constructor of the class TicTacToe. Call the Reset method. It creates and initializes the game. | |
| void | DrawGame (void) |
| Draw the game in text mode (console mode). This method uses cout to draw the game, it assumes that cout can be used. | |
| void | Reset (void) |
| Set the game in its initial configuration. Each cell is filled with the empty symbol. | |
| char | CurrentPlayer (void) |
| Return the mark of the current player (CROSS or CIRCLE). Note that the methods returns a mark even if the game is over. To check if the game is over, uses the GameOver method. | |
| char | Play (int NumCell) |
| Place the mark of the current player on the grid in the cell NumCell if it is possible. | |
| int | Undo (void) |
| Undo the last move. | |
| char | GameOver (void) |
| Analyse the current state of the game. | |
This class can managed a Tic-Tac-Toe game. The class allows basic operations like initializing the game, placing marks according to the rules, checking if the game is over, undo a move etc ...
Definition at line 39 of file tictactoe.h.
| TicTacToe::TicTacToe | ( | void | ) |
Constructor of the class TicTacToe. Call the Reset method. It creates and initializes the game.
Definition at line 19 of file tictactoe.cpp.
| char TicTacToe::CurrentPlayer | ( | void | ) |
Return the mark of the current player (CROSS or CIRCLE). Note that the methods returns a mark even if the game is over. To check if the game is over, uses the GameOver method.
Definition at line 66 of file tictactoe.cpp.
| void TicTacToe::DrawGame | ( | void | ) |
Draw the game in text mode (console mode). This method uses cout to draw the game, it assumes that cout can be used.
Definition at line 42 of file tictactoe.cpp.
| char TicTacToe::GameOver | ( | void | ) |
Analyse the current state of the game.
Definition at line 114 of file tictactoe.cpp.
| char TicTacToe::Play | ( | int | NumCell | ) |
Place the mark of the current player on the grid in the cell NumCell if it is possible.
| NumCell | : ID of the cell where the current player will place its mark |
Definition at line 79 of file tictactoe.cpp.
| void TicTacToe::Reset | ( | void | ) |
Set the game in its initial configuration. Each cell is filled with the empty symbol.
Definition at line 28 of file tictactoe.cpp.
| int TicTacToe::Undo | ( | void | ) |
Undo the last move.
Definition at line 96 of file tictactoe.cpp.
Tic-Tac-Toe by
1.7.3