Пример #1
0
        public string PlayAHand()
        {
            string winner = "Nobody yet";

            // Start out with a initialed and shuffled deck
            CardDeck deck = new CardDeck();

            deck.Shuffle();
            // Deal two cards
            Card card1 = deck.Deal();
            Card card2 = deck.Deal();

            //Added to show cards
            Cards    = new Card[2];
            Cards[0] = card1;
            Cards[1] = card2;

            // Compare the cards
            //Suit doesn't matter
            if (card1.Face == card2.Face)
            {
                winner = "Tie";
            }
            else if (card1.Face > card2.Face || card1.Face == 0)
            {
                winner = "Player 1 wins";
            }
            else if (card1.Face > card2.Face || card2.Face == 0)
            {
                winner = "Player 2 wins";
            }

            // Whoever has the higher card wins
            return(winner);
        }
        private void DisplayDeck()
        {
            var card = deck.Deal();

            while (card != null)
            {
                Console.WriteLine(card);
                card = deck.Deal();
            }
        }
Пример #3
0
        private void DisplayDeck()
        {
            var card = deck.Deal();

            for (int i = 0; i < CardDeck.NUMBER_OF_FACES * CardDeck.NUMBER_OF_SUITS + 2; i++)
            //while (card != null)
            {
                Console.WriteLine($"{ card} { i.ToString()}");
                card = deck.Deal();
            }
        }