Blackjack Program  Iteration 2
Core Exercise HIT3172
 All Classes Functions Variables Enumerations Enumerator
Public Member Functions | Private Member Functions | Private Attributes | List of all members
blackjack_hand Class Reference

Public Member Functions

 blackjack_hand ()
void add_card (card *)
void return_cards ()
cardcard_at (int)
void reveal ()
std::string str ()
int get_score ()
int get_count ()
bool is_full ()
bool is_blackjack ()
bool is_busted ()

Private Member Functions

bool needs_evaluate ()
void evaluate ()

Private Attributes

card_cards [MAX_CARDS_IN_HAND]
int _score
int _count

Constructor & Destructor Documentation

blackjack_hand::blackjack_hand ( )

Initialise the blackjack hand

Member Function Documentation

void blackjack_hand::add_card ( card card)

Add a new card to the hand. If the hand is full and cannot take any more cards this method silently fails

Parameters
cardthe card object to add to the hand
card * blackjack_hand::card_at ( int  idx)

Get a pointer to a card in the hand

Parameters
idxthe index of the card
Returns
the card pointer, or NULL if that index has no card
void blackjack_hand::evaluate ( )
private

Calculates the score of the hand

int blackjack_hand::get_count ( )

Get the number of cards in the hand

Returns
number of cards in the hand
int blackjack_hand::get_score ( )

Get the hand score

Returns
the hand score
bool blackjack_hand::is_blackjack ( )

Check if the hand has blackjack

Returns
if the hand has blackjack
bool blackjack_hand::is_busted ( )

Check if the hand is bust

Returns
if the hand is bust
bool blackjack_hand::is_full ( )

Check if the hand is full (ie. cannot take any more cards)

Returns
if the hand is full
bool blackjack_hand::needs_evaluate ( )
private

Checks if the hand needs evaluating

Returns
boolean true/false
void blackjack_hand::return_cards ( )

Removes all cards from its cards field, sets count to 0

void blackjack_hand::reveal ( )

Turns all cards face up

string blackjack_hand::str ( )

Creates a string representation of the blackjack hand

Returns
a string representation of the blackjack hand

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