proj home

Files   Classes   Functions   Hierarchy  

hand.cpp

Go to the documentation of this file.
00001 #include <hand.h>
00002 
00003 
00004 bool const hand::isbusted() const
00005 {
00006   if (calculate()>21)
00007     return true;
00008 
00009   return false;
00010 }
00011 
00012 
00013 void hand::reset()
00014 {
00015   hasAce=false;
00016   value=0;
00017 }
00018 
00019 void hand::reset(uintc card)
00020 {
00021   hasAce=false;
00022   value=0;
00023 
00024   add(card);
00025 }
00026 
00027 
00028 
00029 void hand::add(uintc card)
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 }
00045 
00046 
00047 uintc hand::calculate() const
00048 {
00049   if (hasAce==false)
00050     return value;
00051 
00052   if (value+11<=21)
00053     return value+11;
00054 
00055   return value + 1;
00056 }
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 

Generated on Fri Mar 4 00:49:30 2011 for Chelton Evans Source by  doxygen 1.5.8