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

#include <board.h>

Collaboration diagram for Board:
Collaboration graph
[legend]

Public Member Functions

 Board ()
 
 ~Board ()
 
SquaregetSquare (int r, int c)
 
void show ()
 
bool placeTile (Tile *t, int r, int c)
 
void placeTileStr (Rack *rack, std::vector< Tile * > tilesInStr, int r, int c, char dir)
 
Tileretrieve (int r, int c)
 

Private Attributes

Squareboard [NUM_ROWS][NUM_COLS]
 
std::array< std::string, 5 > sqStrings
 

Detailed Description

Implements the Scrabble board

The board is a 2D matrix of pointers to Square objects

Definition at line 20 of file board.h.

Constructor & Destructor Documentation

◆ Board()

Board::Board ( )

Board constructor. Fills the 2D board matrix with pointers to Square objects of approproate type. Symmetry of the board is used to easily construct the board. It is done in 2 steps- four square portions and then the 4 strips

Definition at line 18 of file board.cc.

Here is the call graph for this function:

◆ ~Board()

Board::~Board ( )

Clean up all squares on Board

Definition at line 109 of file board.cc.

Member Function Documentation

◆ getSquare()

Square * Board::getSquare ( int  r,
int  c 
)

Get a square from the board

Parameters
rRow where Square to be returned is
cColumn where Square to be returned is
Returns
A pointer to the Square that is requested
Exceptions
std::stringcontaining the error message

Definition at line 321 of file board.cc.

Here is the caller graph for this function:

◆ placeTile()

bool Board::placeTile ( Tile t,
int  r,
int  c 
)

Place a Tile on the Board

Parameters
tPointer to the tile to be placed
rRow where the tile should be placed
cColumn where the tile should be placed
Returns
true if placed successfully, false otherwise
Exceptions
std::stringcontaining the error message

Definition at line 213 of file board.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ placeTileStr()

void Board::placeTileStr ( Rack rack,
std::vector< Tile * >  tilesInStr,
int  r,
int  c,
char  dir 
)

Place a series of Tiles on the Board

Parameters
rackPointer to the Rack from where the Tiles are coming
tilesInStrA vector of pointers to the Tiles to be placed
rRow where the first Tile goes
cColumn where the first Tile goes
dirDirection of placement ('h'/'v')
Exceptions
std::stringcontaining the error message

Definition at line 246 of file board.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ retrieve()

Tile * Board::retrieve ( int  r,
int  c 
)

Retrieve a Tile from the Board

Parameters
rRow where Tile to be retrieved is
cColumn where Tile to be retrieved is
Returns
A pointer to the returned Tile, nullptr if unsuccessful

This function shall not throw exceptions.

Definition at line 301 of file board.cc.

Here is the caller graph for this function:

◆ show()

void Board::show ( )

"Pretty print" the board to stdout

Definition at line 121 of file board.cc.

Here is the call graph for this function:

Member Data Documentation

◆ board

Square* Board::board[NUM_ROWS][NUM_COLS]
private

Definition at line 22 of file board.h.

◆ sqStrings

std::array<std::string, 5> Board::sqStrings
private

Definition at line 23 of file board.h.


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