CBG  0.1
Compendium of board games
ConnectFour Class Reference

#include <ConnectFour.h>

Inheritance diagram for ConnectFour:
Game

Public Member Functions

 ConnectFour ()
 
 ~ConnectFour ()
 Deconstructor for Connect Four. More...
 
- Public Member Functions inherited from Game
 Game (const int amountOfPlayers, const int columns, const int rows)
 
virtual ~Game ()
 
virtual void start ()
 

Private Member Functions

bool isLegal (const Square &current, int yOffset, int xOffset) const
 Function to test if the next square is legal. More...
 
bool getMove ()
 
int getPoint (const string message, const int range) const
 Prompts with message to get a point between 0 and range. More...
 
void drawScreen () const
 Prints out the board and all the players pieces. More...
 
int isOver ()
 Overloaded function to to return weather or not the game is over. More...
 
int isOver (const Square &current) const
 
bool isDraw () const
 Functions to test if the game has ended in a draw. More...
 
bool fourInRow (const Square &current) const
 
bool executeMove (int x)
 
int checkNext (const Square &next, int yOffset, int xOffset) const
 
int getOpposition () const
 Returns the opposition. More...
 

Private Attributes

int state
 Int to store the current state of the game. More...
 
vector< int > columnHeight
 Vector to hold how much pieces lie in each column. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Game
void clearScreen () const
 Clears the terminal window. More...
 
- Protected Attributes inherited from Game
int currentPlayer
 Holds the position in the players array of the current player. More...
 
Player ** players
 Holds all of the games players. More...
 
Square ** grid
 Holds all of the squares that makes up the games grid. More...
 
const int amountOfPlayers
 Holds the length of the players array. More...
 
const int columns
 Holds the amount of columns within the grid. More...
 
const int rows
 Holds the amount of rows within the grid. More...
 

Detailed Description

ConnectFour Game.

Author
Darren Brogan

Constructor & Destructor Documentation

ConnectFour::ConnectFour ( )
ConnectFour::~ConnectFour ( )

Deconstructor for Connect Four.

Member Function Documentation

int ConnectFour::checkNext ( const Square current,
int  yOffset,
int  xOffset 
) const
private

Recursive function to check the next square to see if it has a piece to see if it's owned by current player.

void ConnectFour::drawScreen ( ) const
privatevirtual

Prints out the board and all the players pieces.

Implements Game.

bool ConnectFour::executeMove ( int  x)
private

Function to take an int representing a column and move a piece to the next available slot in that column.

bool ConnectFour::fourInRow ( const Square current) const
private

Function to get the max amount of pieces in a line around the piece added returns weather or not the number is greater than 3, signifying a win.

bool ConnectFour::getMove ( )
privatevirtual

Function to request a move from the user and read it in Pass move to executeMove().

Implements Game.

int ConnectFour::getOpposition ( ) const
private

Returns the opposition.

int ConnectFour::getPoint ( const string  message,
const int  range 
) const
private

Prompts with message to get a point between 0 and range.

bool ConnectFour::isDraw ( ) const
private

Functions to test if the game has ended in a draw.

bool ConnectFour::isLegal ( const Square current,
int  yOffset,
int  xOffset 
) const
private

Function to test if the next square is legal.

int ConnectFour::isOver ( )
privatevirtual

Overloaded function to to return weather or not the game is over.

Implements Game.

int ConnectFour::isOver ( const Square current) const
private

Member Data Documentation

vector<int> ConnectFour::columnHeight
private

Vector to hold how much pieces lie in each column.

int ConnectFour::state
private

Int to store the current state of the game.


The documentation for this class was generated from the following files: