Make your own free website on
Main Page | Class Hierarchy | Class List | File List | Class Members

Board Class Reference

The tic-tac-toe Board. More...

#include <board.h>

Inheritance diagram for Board:

CBoard List of all members.

Public Member Functions

 Board (char icon, char otherIcon)
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]

Detailed Description

The tic-tac-toe Board.

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

See also:
Jesse H-K
Jan 18th, 2006

Constructor & Destructor Documentation

Board::Board char  icon,
char  otherIcon


icon The label that is assigned to the player (eg: \'x\' or \'o\')
otherIcon The label that is assigned to the opposite player. Should be the opposite of icon

Member Function Documentation

bool Board::checkCats  )  const

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).

true if there is a cat's game, false otherwise.

bool Board::checkWin  ) 

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.

true if there is a winner, false otherwise

bool Board::makeMove int  space  ) 

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.

space The space where the player's icon should be placed relative to the numpad
True if move is made successfully, false otherwise

void Board::reset  ) 

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.

void Board::show  )  const

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

The documentation for this class was generated from the following files:
Generated on Thu Jan 19 19:15:21 2006 for TicTacToe by  doxygen 1.4.4