CBG  0.1
Compendium of board games
SnakesAndLadders Class Reference

#include <SnakesAndLadders.h>

Inheritance diagram for SnakesAndLadders:
Game

Public Member Functions

 SnakesAndLadders ()
 
 ~SnakesAndLadders ()
 Deconstructor for snakes and ladders. 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

void drawScreen () const
 Prints out the board, players, snakes and ladders. More...
 
int rollDice () const
 Generate a random number between 1 and 6. More...
 
bool getMove ()
 
bool executeMove (Square *sourceSquare, Square *destinationSquare) const
 Moves the piece on srcSquare to destSquare. More...
 
Coordinate squareToCoordinate (int position) const
 Converts an square identifier to a coordinate. More...
 
bool printSnakeLadder (int x, int y) const
 Prints a snake and ladder at coordinates x,y. More...
 
int isOver ()
 Check if square with identifier 100 is occupied. More...
 

Private Attributes

Square ** squareRefs
 Pointers to the squares based on their identifiers. More...
 
PlayersystemItems
 Array that holds the snakes and ladder character representations. More...
 
const int amountOfSystemItems
 Amount of system items. 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

Snakes and Ladders Game.

Author
Ian Duffy
Darren Brogan

Constructor & Destructor Documentation

SnakesAndLadders::SnakesAndLadders ( )
SnakesAndLadders::~SnakesAndLadders ( )

Deconstructor for snakes and ladders.

Member Function Documentation

void SnakesAndLadders::drawScreen ( ) const
privatevirtual

Prints out the board, players, snakes and ladders.

Implements Game.

bool SnakesAndLadders::executeMove ( Square sourceSquare,
Square destinationSquare 
) const
private

Moves the piece on srcSquare to destSquare.

bool SnakesAndLadders::getMove ( )
privatevirtual

Calls rollDice() and calculates the destination square Passes these too executeMove().

Implements Game.

int SnakesAndLadders::isOver ( )
privatevirtual

Check if square with identifier 100 is occupied.

Implements Game.

bool SnakesAndLadders::printSnakeLadder ( int  x,
int  y 
) const
private

Prints a snake and ladder at coordinates x,y.

int SnakesAndLadders::rollDice ( ) const
private

Generate a random number between 1 and 6.

Coord SnakesAndLadders::squareToCoordinate ( int  position) const
private

Converts an square identifier to a coordinate.

Member Data Documentation

const int SnakesAndLadders::amountOfSystemItems
private

Amount of system items.

Square** SnakesAndLadders::squareRefs
private

Pointers to the squares based on their identifiers.

Player* SnakesAndLadders::systemItems
private

Array that holds the snakes and ladder character representations.


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