Maintains the state of a game of Tic-Tac-Toe.
More...
#include <tic_tac_toe.h>
|
| | TicTacToe () |
| | Creates a new game with empty board and player X's turn.
|
| |
| void | clear_board () |
| | Resets the board for a new game.
|
| |
| Mark | get_mark (int i, int j) const |
| |
| void | put_mark (int i, int j) |
| |
| bool | is_win (Mark mark) |
| | Checks whether the board configuration is a win for the given player.
|
| |
| Mark | get_winner () |
| | Returns the winning player's mark, or EMPTY to indicate a tie or unfinished game.
|
| |
Maintains the state of a game of Tic-Tac-Toe.
◆ Mark
◆ TicTacToe()
| dsac::array::TicTacToe::TicTacToe |
( |
| ) |
|
|
inline |
Creates a new game with empty board and player X's turn.
◆ clear_board()
| void dsac::array::TicTacToe::clear_board |
( |
| ) |
|
|
inline |
Resets the board for a new game.
◆ get_mark()
| Mark dsac::array::TicTacToe::get_mark |
( |
int |
i, |
|
|
int |
j |
|
) |
| const |
|
inline |
Returns current content of position (i,j), which might be X, O, or EMPTY
- Exceptions
-
| invalid_argument | if (i,j) out of range |
- Returns
- X, O or EMPTY
◆ get_winner()
| Mark dsac::array::TicTacToe::get_winner |
( |
| ) |
|
|
inline |
Returns the winning player's mark, or EMPTY to indicate a tie or unfinished game.
◆ is_win()
| bool dsac::array::TicTacToe::is_win |
( |
Mark |
mark | ) |
|
|
inline |
Checks whether the board configuration is a win for the given player.
◆ put_mark()
| void dsac::array::TicTacToe::put_mark |
( |
int |
i, |
|
|
int |
j |
|
) |
| |
|
inline |
Puts a mark at position (i,j) for current player
- Exceptions
-
| invalid_argument | if (i,j) out of range or non-empty |
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & |
out, |
|
|
TicTacToe |
game |
|
) |
| |
|
friend |
Display board on output stream.
The documentation for this class was generated from the following file: