#include <board.h>
Inheritance diagram for Board:
Public Member Functions | |
Board (char icon, char otherIcon) | |
Constructor. | |
void | reset () |
Reset the game board. | |
bool | makeMove (int space) |
Perfom a move on the board. | |
bool | checkWin () |
Check for a winner. | |
void | show () const |
Display the board. | |
bool | checkCats () const |
Check for a cat's game. | |
Static Protected Attributes | |
static char | board [3][3] |
The Board class provides the means to play a human controlled game of tictactoe. It provides methods such as makeMove(), checkWin(), etc. To use a computer-controlled character, see CBoard
|
Constructor.
|
|
Check for a cat's game. This method will check for a cat's game (that is, all spaces are taken, and no other moves are possible).
|
|
Check for a winner. This method will check to see if there are 3 spaces occupied by the player's icon in either a row, column, or diagonal.
|
|
Perfom a move on the board. The computer will perform a move on the board provided that the space is not taken. In the event of a bad move (the space is taken, or bad input is given), the method will return false, and no changes will be made to the board. The spaces are modeled after the numpad, so a move in the upper-right would equal 7, while a move in the center would be 5.
|
|
Reset the game board. It is necessary to reset the game board before applying any actions to the board. The board should be reset before every new game. |
|
Display the board. This method will display the tic-tac-toe board with the appropriate spaces taken up by the different players. It is necessary to show the board after every move, or the player will be unaware that any change to the game took place |