/** * Reference to the function declaration */ void BlackJackCardTable::processPlayerTurn() { int usrReq; //user request bool isHOS; //is hit over stay do { isHOS = false; cout << "Would you like to hit(1) or stay(2) ? "; CardTableHelper::validateValueOf(usrReq, BJ_PLAYER_HIT, BJ_PLAYER_HIT + 1); if (usrReq == BJ_PLAYER_HIT) { crCards.push_back(dealsNewCard()); CardTableHelper::clearMonitor(); displayDealerCards(); displayCards(crCards); isHOS = true; } } while (isHOS && (crCards.size() < BJ_PLAYER_CARD_LIMIT)); }
int main(void) { // seed a random value so function rand() won't return the same value seedRand(); // call the displayCards function which starts the game displayCards(); return 0; }
/** * Reference to the function declaration * @param isPD : is the player done. */ void BlackJackCardTable::displayDealerCards(bool isPD) { if (!isPD) { cout << "Dealer has:\n"; //Display only the second card being occupied the dealer cout << "Card 1: Secret!!!\n"; cout << "Card 2: " << CARD_SUIT_LABELS[crDCrds[1]->suit] << "-"; cout << CARD_RANK_LABELS[crDCrds[1]->rank] << " " << endl; return; } //After the player finished his or her turn, show all dealer 's cards displayCards(crDCrds, "Dealer"); }
/** * Reference to the declaration */ CardTableHelper::GAME_BOOL BlackJackCardTable::populateConsole() { //Clean up the lists of cards clean(); //Dealing first four cards for the player and the dealer, alternatively dealsCards(BJ_INIT_N_CARDS); //Show the dealer 's second card on console displayDealerCards(); //Show the player's first two cards on console displayCards(crCards); //Interact with the player for the hit-or-stay process processPlayerTurn(); //Try to make deal win the game processDealerTurn(); return isPlayerWin(); }