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

#include <bag.h>

Public Member Functions

 Bag ()
 
 ~Bag ()
 
void show ()
 
bool isEmpty ()
 
void shuffle ()
 
std::vector< Tile * > draw (int count)
 

Private Attributes

std::vector< Tile * > bag
 

Detailed Description

Implements the bag of tiles used in a traditional game of scrabble.

The bag is a vector of pointers to Tile objects

Definition at line 15 of file bag.h.

Constructor & Destructor Documentation

◆ Bag()

Bag::Bag ( )

Bag constructor "Fills" the bag member vector with "Tiles"

Definition at line 19 of file bag.cc.

◆ ~Bag()

Bag::~Bag ( )

Bag destructor

Definition at line 183 of file bag.cc.

Member Function Documentation

◆ draw()

vector< Tile * > Bag::draw ( int  count)

Draw specified number of Tiles from the Bag.

Parameters
countThe number of Tiles to draw.
Returns
drawn A vector of pointers to the drawn Tiles.

This function shall not throw exceptions.

Definition at line 232 of file bag.cc.

Here is the caller graph for this function:

◆ isEmpty()

bool Bag::isEmpty ( )

Check if bag is empty

Returns
true if empty, false otherwise

This function shall not throw exceptions.

Definition at line 253 of file bag.cc.

◆ show()

void Bag::show ( )

"Pretty print" the Bag.

Definition at line 195 of file bag.cc.

Here is the call graph for this function:

◆ shuffle()

void Bag::shuffle ( )

"Shuffle" the Tiles in the Bag.

Does so by swapping Tiles in the vector to random indices.

Definition at line 208 of file bag.cc.

Member Data Documentation

◆ bag

std::vector<Tile*> Bag::bag
private

Definition at line 17 of file bag.h.


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