public static void Main(string[] args)
        {
            bool play = true;
            while (play)
            {
                RockPaperScissors rps = new RockPaperScissors ();

                Console.WriteLine ("Welcome to RockPaperScissors!");
                Console.WriteLine ("Make your choice: ");
                string user_choice = Console.ReadLine ();

                string computer_choice = rps.ComputerChoice ();

                Console.WriteLine ("The computer chose {0}.", computer_choice);
                Console.WriteLine (rps.Result(user_choice, computer_choice));

                Console.WriteLine ("Play Again? Y/N");
                string play_again = Console.ReadLine ();
                if (play_again == "N")
                {
                    Console.WriteLine("Thanks for playing!");
                    play = false;
                }
            }
        }
        static void Main(string[] args)
        {
            int numberOfRounds;
            int playerScore   = 0;
            int computerScore = 0;

            ShowIntro();

            Console.Write("How many rounds would you like to play (1-100): ");
            if (!InputIsValid(Console.ReadLine(), 1, 100, out int rounds))
            {
                Console.WriteLine("Please enter a valid number of rounds!");
                Console.WriteLine();
                Main(null);
            }

            numberOfRounds = rounds;

            RockPaperScissors rockPaperScissors = new RockPaperScissors();

            for (int i = 0; i < numberOfRounds; i++)
            {
                ShowRoundInfo(playerScore, computerScore, i + 1, numberOfRounds);
                PlayRound(rockPaperScissors, ref playerScore, ref computerScore);
            }

            ShowResults(playerScore, computerScore);
        }
        private static void PlayRound(RockPaperScissors rockPaperScissors, ref int playerScore, ref int computerScore)
        {
            ThrowResult computerThrow = rockPaperScissors.GetComputerThrow();
            ThrowResult playerThrow   = GetPlayerThrow();

            Winner winner = rockPaperScissors.DetermineWinner(playerThrow, computerThrow);

            Console.WriteLine($"You threw: {Enum.GetName(playerThrow)}");
            Console.WriteLine($"The computer threw: {Enum.GetName(computerThrow)}");

            if (winner == Winner.Player1)
            {
                Console.WriteLine("You win this round!");
                playerScore++;
            }
            else if (winner == Winner.Player2)
            {
                Console.WriteLine("The computer won this round!");
                computerScore++;
            }
            else
            {
                Console.WriteLine("It's a tie!");
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            RockPaperScissors rps = new RockPaperScissors();

            rps.StartUp();
            rps.Game();
        }
示例#5
0
 public void Calculate(RockPaperScissors p1, RockPaperScissors c1)
 {
     Console.WriteLine("You chose {0}, Computer chooses {1}.", p1, c1);
     // Player & Computer tie.
     if (p1 == c1)
     {
         Console.WriteLine("You both chose {0}. There is a tie!", p1);
     }
     // Player chooses rock.
     else if (p1 == RockPaperScissors.rock)
     {
         if (c1 == RockPaperScissors.paper)
         {
             Console.WriteLine("Paper covers rock. Computer wins.");
         }
         else
             Console.WriteLine("Rock destroys scissors. You win!!");
     }
     // Player chooses paper.
     else if (p1 == RockPaperScissors.paper)
     {
         if (c1 == RockPaperScissors.rock)
             Console.WriteLine("Paper covers rock. You win!!");
         else
         {
             Console.WriteLine("Scissors cuts paper. Computer wins.");
         }
     }
     // Player chooses scissors.
     else
     {
         if (c1 == RockPaperScissors.rock)
         {
             Console.WriteLine("Rock destroys scissors. Computer wins.");
         }
         else
         {
             Console.WriteLine("Scissors cuts paper. You win!!");
         }
     }
 }
 public void RPSCreation()
 {
     rps = new RockPaperScissors ();
 }
示例#7
0
        static void Main(string[] args)
        {
            var game = new RockPaperScissors();

            game.Play();
        }
 public void TestMethod1()
 {
     var testObject = new RockPaperScissors();
     testObject.DoThing();
 }