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

dealer.cpp

 #include "dealer.h" bool Dealer::DealCard(BlackJackHand* hand) { Card card; if (!theDeck.GetCard(&card)) throw "Bad Deck"; hand->AddCard(card); return true; } bool Dealer::ProcessTurn(BlackJackHand* hand) { bool doneturn = false; bool retval = true; BlackJackHand::TURN_RESULT turn; while (!doneturn) { turn = hand->TakeTurn(); switch (turn) { case BlackJackHand::HIT: DealCard(hand); break; case BlackJackHand::BUST: retval = false; // allow fall through case BlackJackHand::STAND: doneturn = true; break; case BlackJackHand::DOUBLE_DOWN: DealCard(hand); retval = hand->HighCount() > 21; // did we bust doneturn = true; break; case BlackJackHand::SPLIT: throw "Not implemented"; // break; default: throw "Illegal result of move"; } } return ...

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