Пример #1
0
        static void PlayAgainstComputer()
        {
            Random rnd = new Random();
            int    extra1 = rnd.Next(1, 5), extra2 = rnd.Next(1, 5);
            Player player1 = new Player(rnd.Next(1, 5), rnd.Next(1, 5));
            Player player2 = new Player(extra1, extra2);

            Console.WriteLine("Your extra cards are {0}\t{1}", extra1, extra2);

            int score1 = 12, score2 = 12, round = 0;
            int card1, card2;

            while (score1 > 0 && score2 > 0)
            {
                Console.WriteLine("\nRound {0}\t\t{1} VS {2}", ++round, score1, score2);
                card1 = player1.PlayCard();
                card2 = player2.PlayCardByChoice();
                Console.WriteLine("Player1's card: {0}\t\t\tPlayer2's card: {1}", card1, card2);
                score1 = player1.calculateNewScore(card1, card2);
                score2 = player2.calculateNewScore(card2, card1);
                //Console.WriteLine("Player1's score: {0}\tPlayer2's score: {1}", score1, score2);
            }
            string message = score1 > score2 ? "You Lost!!" : "You Win";

            Console.WriteLine(message);
        }