rp-scrabble
Simple, terminal-based Scrabble game
Public Member Functions | Private Attributes | List of all members
Square Class Reference

#include <square.h>

Collaboration diagram for Square:
Collaboration graph
[legend]

Public Member Functions

 Square (enum_sqType st, int r, int c)
 
 ~Square ()
 
int getRow ()
 
int getCol ()
 
int getType ()
 
SquaregetLeft ()
 
SquaregetRight ()
 
SquaregetAbove ()
 
SquaregetBelow ()
 
TilegetTile ()
 
void setLeft (Square *l)
 
void setRight (Square *r)
 
void setAbove (Square *u)
 
void setBelow (Square *d)
 
void setTile (Tile *t)
 
bool isEmpty ()
 
bool checkNeighboursH ()
 
bool checkNeighboursV ()
 
void show ()
 

Private Attributes

enum_sqType sqType
 
TiletileInSquare
 
int row
 
int col
 
Squareleft
 
Squareright
 
Squareabove
 
Squarebelow
 

Detailed Description

Implements a single square on the Scrabble board

Squares can be one of 5 types and can either be empty, or occupied by a Tile

Definition at line 30 of file square.h.

Constructor & Destructor Documentation

◆ Square()

Square::Square ( enum_sqType  st,
int  r,
int  c 
)

Construct a Square

Parameters
stType of Square
rRow where the Square is on the Board
cColumn where the Square is on the Board

This function shall not throw exceptions

Definition at line 19 of file square.cc.

◆ ~Square()

Square::~Square ( )
inline

Definition at line 44 of file square.h.

Member Function Documentation

◆ checkNeighboursH()

bool Square::checkNeighboursH ( )

Check if any neighbour Squares are present to the left, above or below

Returns
true if found, false otherwise

This function shall not throw exceptions.

Definition at line 227 of file square.cc.

◆ checkNeighboursV()

bool Square::checkNeighboursV ( )

Check if any neighbour Squares are present to the left, above or to the right

Returns
true if found, false otherwise

This function shall not throw exceptions.

Definition at line 244 of file square.cc.

◆ getAbove()

Square * Square::getAbove ( )

Getter for member above

Returns
A pointer to the Square that is above the calling object, nullptr if not present

This function shall not throw exceptions.

Definition at line 75 of file square.cc.

Here is the caller graph for this function:

◆ getBelow()

Square * Square::getBelow ( )

Getter for member below

Returns
A pointer to the Square that is below the calling object, nullptr if not present

This function shall not throw exceptions.

Definition at line 87 of file square.cc.

Here is the caller graph for this function:

◆ getCol()

int Square::getCol ( )

Getter for member col

Returns
column number

This function shall not throw exceptions.

Definition at line 111 of file square.cc.

Here is the caller graph for this function:

◆ getLeft()

Square * Square::getLeft ( )

Getter for member left

Returns
A pointer to the Square that is to the left of the calling object, nullptr if not present

This function shall not throw exceptions.

Definition at line 51 of file square.cc.

Here is the caller graph for this function:

◆ getRight()

Square * Square::getRight ( )

Getter for member right

Returns
A pointer to the Square that is to the right of the calling object, nullptr if not present

This function shall not throw exceptions.

Definition at line 63 of file square.cc.

Here is the caller graph for this function:

◆ getRow()

int Square::getRow ( )

Getter for member row

Returns
row number

This function shall not throw exceptions.

Definition at line 99 of file square.cc.

Here is the caller graph for this function:

◆ getTile()

Tile * Square::getTile ( )

Getter for member tileInSquare

Returns
A pointer to the Tile that is in the square, nullptr if empty

This function shall not throw exceptions.

Definition at line 167 of file square.cc.

Here is the caller graph for this function:

◆ getType()

int Square::getType ( )

Getter for member sqType

Returns
type of Square
See also
square.h

This function shall not throw exceptions.

Definition at line 125 of file square.cc.

Here is the caller graph for this function:

◆ isEmpty()

bool Square::isEmpty ( )

Check state of square

Returns
true if empty, false otherwise

This function shall not throw exceptions.

Definition at line 137 of file square.cc.

Here is the caller graph for this function:

◆ setAbove()

void Square::setAbove ( Square u)

Setter for member above

Parameters
uA pointer to the Square to set

This function shall not throw exceptions.

Definition at line 203 of file square.cc.

Here is the caller graph for this function:

◆ setBelow()

void Square::setBelow ( Square d)

Setter for member below

Parameters
dA pointer to the Square to set

This function shall not throw exceptions.

Definition at line 215 of file square.cc.

Here is the caller graph for this function:

◆ setLeft()

void Square::setLeft ( Square l)

Setter for member left

Parameters
lA pointer to the Square to set

This function shall not throw exceptions.

Definition at line 179 of file square.cc.

Here is the caller graph for this function:

◆ setRight()

void Square::setRight ( Square r)

Setter for member right

Parameters
rA pointer to the Square to set

This function shall not throw exceptions.

Definition at line 191 of file square.cc.

Here is the caller graph for this function:

◆ setTile()

void Square::setTile ( Tile t)

Setter for member tileInSquare "Place" a Tile in a Square

Parameters
tPointer to the Tile to pe "placed"

This function shall not throw exceptions.

Definition at line 155 of file square.cc.

Here is the caller graph for this function:

◆ show()

void Square::show ( )

"Pretty print" the square object. Primarily used for debug purposes

Definition at line 32 of file square.cc.

Member Data Documentation

◆ above

Square* Square::above
private

Definition at line 38 of file square.h.

◆ below

Square* Square::below
private

Definition at line 39 of file square.h.

◆ col

int Square::col
private

Definition at line 35 of file square.h.

◆ left

Square* Square::left
private

Definition at line 36 of file square.h.

◆ right

Square* Square::right
private

Definition at line 37 of file square.h.

◆ row

int Square::row
private

Definition at line 34 of file square.h.

◆ sqType

enum_sqType Square::sqType
private

Definition at line 32 of file square.h.

◆ tileInSquare

Tile* Square::tileInSquare
private

Definition at line 33 of file square.h.


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