O'Reilly logo

Joy of Patterns: Using Patterns for Enterprise Development, The by Brandon Goldfedder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

simhand.cpp

// Simulated Player hand body
// Brandon Goldfedder

#include <string.h>
#include "simhand.h"
#include "display.h"

SimulatedPlayerHand::SimulatedPlayerHand(const char* name,
      Displayer *displayer): StandardBlackJackHand(displayer)
{
   id = new char[strlen(name) + 1];
   strcpy(id, name);
}
SimulatedPlayerHand::~SimulatedPlayerHand()
{
   delete[] id;
}

const char* const SimulatedPlayerHand::GetIdentity() const
{
   return id;
}

BlackJackHand::TURN_RESULT SimulatedPlayerHand::TakeTurn()
{
   TURN_RESULT result = STAND;
   if (HighCount() < 17)
      result = HIT;
   else if (HighCount() > 21)
      result = BUST;
   GetDisplayer()->DisplayTurn(*this, result);
   return result;
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required