Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            List <Player> players     = new List <Player>();
            List <Card>   deckOfCards = new List <Card>();

            //Display welcomescreen
            Display.DisplayWelcomeScreen();

            //Get nr of players
            int nrOfPlayers = Player.PickNumberOfPlayers();

            // Assign name to players
            players = Player.NamePlayers(nrOfPlayers);

            bool isPlayingGame = true;

            while (isPlayingGame)
            {
                //Create a new deck of cards
                deckOfCards = Card.CreateCardDeck();

                //Create a Dealer object
                Dealer dealer = new Dealer();

                int deal = 0;

                //Pick cards
                NewDeal(players, deckOfCards, dealer, deal);

                //Let players do their rounds.
                Player.HitOrStand(deckOfCards, players, dealer);

                //Let dealer play the round
                dealer.HitOrStand(deckOfCards, players);

                //Check and display winners
                DisplayWinners(players, nrOfPlayers, dealer);

                //Check if player wants to Quit or Continue
                while (true)
                {
                    Console.WriteLine("Press Y to play another round or N to exit game.");
                    string playerChoice = Console.ReadLine();
                    if (playerChoice.ToLower() == "y") //Play another round.
                    {
                        Player.ResetPlayer(players, nrOfPlayers);

                        //Display welcomescreen
                        Display.DisplayWelcomeScreen();
                        break;
                    }
                    else if (playerChoice.ToLower() == "n") //Time to quit game
                    {
                        Console.WriteLine("Thank you for playing Black Jack!");
                        isPlayingGame = false;
                        System.Threading.Thread.Sleep(500);
                        break;
                    }
                }
            }
        }