public void DrawChoice(Choice choice) { ///choices that are offered switch (choice) { case Choice.Rock: GameImages.DrawRock(x, y); break; case Choice.Scissors: GameImages.DrawScissors(x, y); break; case Choice.Paper: GameImages.DrawPaper(x, y); break; } }
/// <summary> /// Output heading using the console helper /// Ask for the name of the player /// Ask how many rounds the player would like to play /// Ask player to make their choice. /// </summary> public void Run() { bool repeat = true; while (repeat) { ConsoleHelper.OutputHeading("Rock, Paper, Scissors Game"); Console.WriteLine("Please Input Player's name"); name = Console.ReadLine(); Console.WriteLine("How many rounds would you like to play?"); int rounds = GetNumberoOfRounds(); for (var round = 1; round <= rounds; round++) { Console.WriteLine("Round {0} Begins", round); Console.WriteLine("Choose between Rock, Paper, Scissor? "); //Allows players to choose by typing Rock,Paper or Scissors var playerChoice = GetPlayerChoice(); Console.WriteLine(name + "" + " chose: {0}", playerChoice.ToString()); //Allows computer to choose var computerAction = GetComputerChoice(); Console.WriteLine("Your opponent chose: {0}", computerAction.ToString()); //Dictates the point added to each player switch (CalculateResult(playerChoice, computerAction)) { case Result.PlayerWon: Console.WriteLine(name + "" + "won the round! You gained 1 point.\n"); GameImages.DrawThumbsUp(); userPoints++; break; case Result.CPUWon: Console.WriteLine("Computer won the round! Computer gained 1 point.\n"); GameImages.DrawThumbsDown(); computerPoints++; break; case Result.Tie: Console.WriteLine("Round tied. You and the computer gained 1 point.\n"); userPoints++; computerPoints++; break; } DrawChoice(computerFinalChoice); DrawChoice(playerFinalChoice); Console.WriteLine(); } //Displays the result after all rounds has ended Console.WriteLine("Results -Player {0}, Computer {1}", userPoints, computerPoints); if (userPoints == computerPoints) { Console.WriteLine("Game Draw"); } else { bool isPlayerWinner = userPoints > computerPoints; Console.WriteLine("{0} won the game", isPlayerWinner ? "" + name + "" : "Computer"); } repeat = ConsoleHelper.WantToRepeat(); } }