Esempio n. 1
0
        public RPS GenerateRPS()
        {
            var rpsrandom  = new Random();
            RPS randomEnum = (RPS)rpsrandom.Next(0, 3);

            return(randomEnum);
        }
Esempio n. 2
0
        public string GenerateRPS()
        {
            var random     = new Random();
            RPS randomEnum = (RPS)random.Next(1, 3);

            return($"{randomEnum}");
        }
Esempio n. 3
0
 public static bool DoesPlayerWin(RPS player, RPS cpu)
 {
     if ((player == RPS.rock && cpu == RPS.scissors) ||
         (player == RPS.paper && cpu == RPS.rock) ||
         (player == RPS.scissors && cpu == RPS.paper))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 4
0
        public void Game(IPlayer opponentSelection, RPS humanselection)
        {
            RPS opponentchoice = opponentSelection.GenerateRPS();



            RPS playerChoice = opponentchoice;

            Console.WriteLine($"You chose: {humanselection}");
            Console.WriteLine($"Opponent chose: {playerChoice}");

            if (humanselection == playerChoice)
            {
                Console.WriteLine("Draw!");
            }
            else if (humanselection == RPS.Paper && playerChoice == RPS.Rock)
            {
                Console.WriteLine("You win!");
                YourPoints++;
            }
            else if (humanselection == RPS.Scissors && playerChoice == RPS.Paper)
            {
                Console.WriteLine("You win!");
                YourPoints++;
            }
            else if (humanselection == RPS.Rock && playerChoice == RPS.Scissors)
            {
                Console.WriteLine("You win!");
                YourPoints++;
            }
            else if (humanselection == RPS.Rock && playerChoice == RPS.Paper)
            {
                Console.WriteLine("You lose!");
                ComputerPoints++;
            }
            else if (humanselection == RPS.Paper && playerChoice == RPS.Scissors)
            {
                Console.WriteLine("You lose!");
                ComputerPoints++;
            }
            else if (humanselection == RPS.Scissors && playerChoice == RPS.Rock)
            {
                Console.WriteLine("You lose!");
                ComputerPoints++;
            }



            Console.WriteLine($"Your score: {YourPoints}");
            Console.WriteLine($"Opponent score: {ComputerPoints}");
        }