proj home

Files   Classes   Functions   Hierarchy  

playerGame Class Reference

#include <playerGame.h>

Inheritance diagram for playerGame:
Collaboration diagram for playerGame:

List of all members.

Public Member Functions

void notalive_dealCards ()
void alive_hold ()
void alive_play ()
void alive_doubleAndPlay ()
 playerGame ()
 ~playerGame ()

Public Attributes

deckcards
dealerdeal
hand player
uint dealerWins
uint playerWins
uint bet
bool alive


Detailed Description

Definition at line 8 of file playerGame.h.


Constructor & Destructor Documentation

playerGame::playerGame (  ) 

Definition at line 10 of file playerGame.cpp.

References alive, cards, deal, dealerWins, and playerWins.

00011 {
00012   dealerWins=0;
00013   playerWins=0;
00014 
00015   cards = new deckpontoon();
00016   deal = new dealer(*cards);
00017 
00018   alive=false;
00019 }

playerGame::~playerGame (  ) 

Definition at line 21 of file playerGame.cpp.

References cards, and deal.

00022 {
00023   delete deal;
00024   deal=0;
00025 
00026   delete cards;
00027   cards=0;
00028 }


Member Function Documentation

void playerGame::alive_doubleAndPlay (  ) 

Definition at line 101 of file playerGame.cpp.

References alive, alive_play(), and bet.

Referenced by textGame::textGame().

00102 {
00103   assert(alive==true);
00104 
00105   bet *= 2;
00106   alive_play();
00107 }

void playerGame::alive_hold (  ) 

Definition at line 46 of file playerGame.cpp.

References alive, bet, deal, dealerWins, dealer::hnd, hand::isbusted(), dealer::play(), player, playerWins, and hand::value.

Referenced by textGame::textGame().

00047 {
00048   assert(alive==true);
00049 
00050   assert(player.isbusted()==false);
00051 
00052   deal->play();
00053 
00054   alive=false;
00055 
00056   if (deal->hnd.isbusted())
00057   {
00058     playerWins += bet;
00059     return;
00060   }
00061 
00062   if (deal->hnd.value > player.value)
00063   {
00064     dealerWins += bet;
00065     return;
00066   }
00067 
00068   if (deal->hnd.value < player.value)
00069   {
00070     playerWins += bet;
00071     return;
00072   }
00073 
00074   // Draw game then do nothing.
00075 }

void playerGame::alive_play (  ) 

Definition at line 78 of file playerGame.cpp.

References hand::add(), alive, bet, hand::calculate(), cards, dealerWins, deck::draw(), hand::isbusted(), player, and playerWins.

Referenced by alive_doubleAndPlay(), and textGame::textGame().

00079 {
00080   assert(alive==true);
00081 
00082   player.add(cards->draw());
00083   if (player.isbusted())
00084   {
00085     alive=false; 
00086     dealerWins += bet;
00087     return;
00088   }
00089 
00090   if (player.calculate()==21)
00091   {
00092     alive=false; 
00093     playerWins += bet;
00094     return;
00095   }
00096 
00097   
00098 }

void playerGame::notalive_dealCards (  ) 

Definition at line 31 of file playerGame.cpp.

References hand::add(), alive, bet, cards, deal, deck::draw(), dealer::hnd, player, and hand::reset().

Referenced by textGame::textGame().

00032 {
00033   assert(alive==false);
00034 
00035   player.reset();
00036   player.add(cards->draw());
00037   deal->hnd.reset();
00038   deal->hnd.add(cards->draw());
00039 
00040   bet=1;
00041 
00042   alive=true;
00043 }


Member Data Documentation

Definition at line 25 of file playerGame.h.

Referenced by alive_doubleAndPlay(), alive_hold(), alive_play(), and notalive_dealCards().

Definition at line 13 of file playerGame.h.

Referenced by alive_play(), notalive_dealCards(), playerGame(), and ~playerGame().

Definition at line 20 of file playerGame.h.

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

Definition at line 17 of file playerGame.h.

Referenced by alive_hold(), alive_play(), notalive_dealCards(), and textGame::printGameState().

Definition at line 22 of file playerGame.h.

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


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

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