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;
}

Get Joy of Patterns: Using Patterns for Enterprise Development, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.