Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string answer = "";

            Console.WriteLine("Welcome to Rock Paper Scissors!\n");
            Console.WriteLine("Enter your name:");
            string PlayerName = Console.ReadLine();

            Console.WriteLine("\nWould you like to play against The Jets or The Sharks (j/s)?:\n");
            string Choice         = Console.ReadLine();
            string OpponentChoice = Validator.validate(Choice);

            do
            {
                Console.WriteLine("\nRock, paper, or scissors? (R/P/S):");
                string Playerchoice = Console.ReadLine();
                Validator.validatechoice(Playerchoice);
                AIplayer p2 = new AIplayer();

                Humanplayer p1 = CreatePlayer(PlayerName, Playerchoice);

                if (OpponentChoice == "j")
                {
                    RockGame(p1);
                }
                else
                {
                    AIGame(p1, p2);
                }
                Console.WriteLine("play again");
                answer = Console.ReadLine();
            }while (answer == "y");
        }
Ejemplo n.º 2
0
 public static object CreateOpponent(string opponent)
 {
     if (opponent == "j")
     {
         Rockplayer TheJets = new Rockplayer();
         return(TheJets);
     }
     else
     {
         AIplayer TheSharks = new AIplayer();
         return(TheSharks);
     }
 }
Ejemplo n.º 3
0
        public static void AIGame(Humanplayer player, AIplayer computer)
        {
            string data = computer.GenerateRoshambo();

            if (player.roshambovalue == "rock")
            {
                if (computer.roshambovalue == "rock")
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\nDraw!");
                }

                else if (computer.roshambovalue == "paper")
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\nTheSharks win!");
                }

                else
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\n{player.name} Wins!");
                }
            }
            else if (player.roshambovalue == "paper")
            {
                if (computer.roshambovalue == "rock")
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\n{player.name} Wins!");
                }

                else if (computer.roshambovalue == "paper")
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\nDraw!");
                }

                else
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\nTheSharks Win!");
                }
            }
            else
            {
                if (computer.roshambovalue == "rock")
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\nTheSharks win!");
                }

                else if (computer.roshambovalue == "paper")
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\n{player.name} Wins!");
                }

                else
                {
                    Console.WriteLine($"{ player.name}: {player.roshambovalue}");
                    Console.WriteLine($"TheSharks: {computer.roshambovalue}\nDraw!");
                }
            }
        }