proj home

Files   Classes   Functions   Hierarchy  

hand Class Reference

#include <hand.h>

Collaboration diagram for hand:

List of all members.

Public Member Functions

uintc calculate () const
 Calculated the greatest value of the hand.
void add (uintc card)
 Add a card to the hand.
bool const isbusted () const
 Is the hand busted/lost?
void reset ()
 Remove all cards from the hand.
void reset (uintc card)
 Remove all cards from the hand and add the new card.

Public Attributes

uint value
 The sum of cards excluding the first ace.
bool hasAce
 Has the hand got this non-unique card.


Detailed Description

Definition at line 13 of file hand.h.


Member Function Documentation

void hand::add ( uintc  card  ) 

Add a card to the hand.

Definition at line 29 of file hand.cpp.

References hasAce, and value.

Referenced by playerGame::alive_play(), playerGame::notalive_dealCards(), and dealer::play().

00030 {
00031   if (card!=1)
00032   {
00033     value += card;
00034     return;
00035   }
00036 
00037   if (hasAce)
00038   {
00039     value += card;
00040     return;
00041   }
00042 
00043   hasAce = true;
00044 }

uintc hand::calculate (  )  const

Calculated the greatest value of the hand.

Definition at line 47 of file hand.cpp.

References hasAce, and value.

Referenced by playerGame::alive_play(), isbusted(), dealer::playAgainst(), and textGame::printGameState().

00048 {
00049   if (hasAce==false)
00050     return value;
00051 
00052   if (value+11<=21)
00053     return value+11;
00054 
00055   return value + 1;
00056 }

bool const hand::isbusted (  )  const

Is the hand busted/lost?

Definition at line 4 of file hand.cpp.

References calculate().

Referenced by playerGame::alive_hold(), and playerGame::alive_play().

00005 {
00006   if (calculate()>21)
00007     return true;
00008 
00009   return false;
00010 }

void hand::reset ( uintc  card  ) 

Remove all cards from the hand and add the new card.

Definition at line 19 of file hand.cpp.

References hasAce, and value.

00020 {
00021   hasAce=false;
00022   value=0;
00023 
00024   add(card);
00025 }

void hand::reset (  ) 

Remove all cards from the hand.

Definition at line 13 of file hand.cpp.

References hasAce, and value.

Referenced by playerGame::notalive_dealCards(), and dealer::playAgainst().

00014 {
00015   hasAce=false;
00016   value=0;
00017 }


Member Data Documentation

Has the hand got this non-unique card.

Definition at line 27 of file hand.h.

Referenced by add(), playerGameSimulate::calculate(), calculate(), playerGameSimulate::calculateHit(), textGame::printGameState(), and reset().

The sum of cards excluding the first ace.

Definition at line 24 of file hand.h.

Referenced by add(), playerGame::alive_hold(), playerGameSimulate::calculate(), calculate(), playerGameSimulate::calculateHit(), dealer::play(), and reset().


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

Generated on Fri Mar 4 00:50:02 2011 for Chelton Evans Source by  doxygen 1.5.8