/** * Give the player one card. Check if the hand value is now over 21. * If so, return true, otherwise return false. * @param class Deck $deck * @return boolean */ public function hitMe($deck) { parent::addCard($deck); $value = parent::calcValue(); if ($value > 21) { return true; } else { return false; } }
/** * Give the dealer cards until hand value is 17 or higher. * Check if the hand value is now over 21. * If so, return true, otherwise return false. * @param class Deck $deck * @return boolean */ public function hitDealer($deck) { // Add cards to the hand while (parent::calcValue() < 17) { parent::addCard($deck); } // Check if dealer busts $value = parent::calcValue(); if ($value > 21) { return true; } else { return false; } }