Пример #1
0
        public void DealCard(Hand hand, bool faceup)
        {
            var card = cardDeck.Draw();     // Draw a card from the deck

            card.FaceUp = faceup;           // Face it up or down
            if (hand == DealerHand && DealerHand.HandTotal() >= 17)
            {
                return;
            }

            hand.Cards.Add(card);                 // Give it the player's hand
        }
Пример #2
0
        public string Stand()
        {
            int userTotal   = UserHand.HandTotal();
            int dealerTotal = DealerHand.HandTotal();

            if (userTotal <= 21)
            {
                if (Math.Abs(21 - userTotal) < Math.Abs(21 - dealerTotal))
                {
                    return("user");
                }
            }
            if (userTotal <= 21 && userTotal == dealerTotal)
            {
                return("draw");
            }

            return("dealer");
        }