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

#include <rack.h>

Public Member Functions

 Rack ()
 
 ~Rack ()
 
TilegetTile (char ch)
 
std::vector< Tile * > getTileStrVec (std::string tileStr)
 
void fill (std::vector< Tile * > t)
 
void addTile (Tile *t)
 
bool isEmpty ()
 
void show ()
 

Private Attributes

std::array< Tile *, 7 > rack
 

Detailed Description

Implements a rack

A rack is an std::array of pointers Tile objects

Definition at line 17 of file rack.h.

Constructor & Destructor Documentation

◆ Rack()

Rack::Rack ( )

Init rack with nullptr

Definition at line 14 of file rack.cc.

◆ ~Rack()

Rack::~Rack ( )

Clean up rack

Definition at line 22 of file rack.cc.

Member Function Documentation

◆ addTile()

void Rack::addTile ( Tile t)

Add a Tile to the rack

Parameters
tA pointer to the Tile to be placed in the rack

This function shall not throw exceptions.

Definition at line 120 of file rack.cc.

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

◆ fill()

void Rack::fill ( std::vector< Tile * >  t)

Fill the rack with provided tiles

Parameters
tA vector of pointers to the Tiles to be put in the rack

This function shall not throw exceptions.

Definition at line 99 of file rack.cc.

◆ getTile()

Tile * Rack::getTile ( char  ch)

Request a Tile from the rack

Parameters
chCharacter representing the Tile
Returns
Pointer to the requested Tile if the Tile exists, nullptr otherwise

This function shall not throw exceptions

Definition at line 80 of file rack.cc.

◆ getTileStrVec()

vector< Tile * > Rack::getTileStrVec ( std::string  tileStr)

Get a vector of the Tiles requested from the rack

Parameters
tileStrA string of letters that represent Tiles
Returns
A vector of pointers to the requested Tiles
Exceptions
std::stringcontaining the error message

Definition at line 141 of file rack.cc.

◆ isEmpty()

bool Rack::isEmpty ( )

Check whether rack is empty

Returns
true if empty, false otherwise

This function shall not throw exceptions.

Definition at line 172 of file rack.cc.

◆ show()

void Rack::show ( )

"Pretty print" the rack

Definition at line 34 of file rack.cc.

Here is the call graph for this function:

Member Data Documentation

◆ rack

std::array<Tile*, 7> Rack::rack
private

Definition at line 19 of file rack.h.


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