Пример #1
0
        public static void initialDeal(int numberCardsPerPlayer, int numberPlayers, CardHand[] player, DeckOfCards shuffled_Deck)
        {//Deals two cards to each player in increasing order.  Also, records player's names during the process.
            string name;

            for (int j = 0; j < numberCardsPerPlayer; j++)
            {
                for (int i = 0; i <= numberPlayers; i++)
                {
                    if (j == 0)
                    {
                        if (i != numberPlayers)
                        {
                            Console.WriteLine("Enter Player {0}'s name:", i + 1);
                            name = Console.ReadLine();
                        }
                        else
                        {
                            name = "Dealer";
                        }
                        player[i] = new CardHand(name);
                    }
                    player[i].TakeCard(shuffled_Deck.DealCard());
                }
            }
        }
Пример #2
0
        public static void Play_Blackjack()
        {
            int    numberCards_InitialDeal_Blackjack = 2;
            int    numberPlayers = 0;
            string continuePlay;

            //Generate Shuffled deck
            DeckOfCards shuffled_Deck = new DeckOfCards(1);

            //Number of players
            Console.Clear();
            Console.Write("Enter the number of players: ");
            Int32.TryParse(Console.ReadLine(), out numberPlayers);

            //Initial Deal
            //Assume last player is dealer.
            CardHand[] playerHand = new CardHand[numberPlayers + 1];
            initialDeal(numberCards_InitialDeal_Blackjack, numberPlayers, playerHand, shuffled_Deck);

            //For each player, display hand; only show first card of all opponents including dealer.
            Console.Clear();
            playerDecisions(playerHand, shuffled_Deck);
            dealerDecisions(playerHand, shuffled_Deck);

            DisplayGameStatus(playerHand);
            Console.WriteLine("Would you like to play again? Y/N");
            continuePlay = Console.ReadLine();
            if (continuePlay.ToUpper() == "Y")
            {
                Play_Blackjack();
            }
            else
            {
                System.Environment.Exit(0);
            }
        }