コード例 #1
0
ファイル: Program.cs プロジェクト: JoshBurgess46/Lab-13-RPS
        static void Main(string[] args)
        {
            Player user = new ThirdPlayer();
            Player opponent;

            Console.WriteLine("Welcome to the Rock, Paper, Scissors World Championship!");
            Console.WriteLine("Please enter your name.");
            user.Name = Console.ReadLine().ToLower();
            bool go = true;

            while (go)
            {
                Console.WriteLine($"{user.Name}, choose your oppenent Jimbo or Grant(j/g)");
                string input = Console.ReadLine().ToLower();

                if (input == "j")
                {
                    opponent = new Jimbo();
                    RoshamboApp.RpsMatch(user, opponent);
                }
                else if (input == "g")
                {
                    opponent = new Grant_Cirpus();
                    RoshamboApp.RpsMatch(user, opponent);
                }

                go = Continue();
            }
        }
コード例 #2
0
        public Player Choose()
        {
            int number = 0;


            Console.WriteLine("Which player would you like to play as? Enter 1 to play as yourself, 2 to play as Serena Williams or 3 to play as David Beckham?");
            string input = Console.ReadLine();

            while (!int.TryParse(input, out number) || number < 1 || number > 3)
            {
                Console.WriteLine("This is not valid input. Please enter 1, 2 or 3.");
                input = Console.ReadLine();
            }

            if (number == 1)
            {
                Player MyThirdPlayer = new ThirdPlayer();
                return(MyThirdPlayer);
            }
            else if (number == 2)
            {
                Player MyRockPlayer = new RockPlayer();
                return(MyRockPlayer);
            }
            else
            {
                Player MyRandomPlayer = new RandomPlayer();
                return(MyRandomPlayer);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Danny7Carter/Lab13RPS
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Rock Paper Scissors!");
            Console.WriteLine();
            Console.WriteLine("Enter your name:");
            ThirdPlayer Yourself = new ThirdPlayer();

            Yourself.PlayerName = Console.ReadLine();

            int input = 0;



            while (true)
            {
                Console.WriteLine("Which player would you like to play against? Serena(1) or David(2)?");
                input = Convert.ToInt32(Console.ReadLine());


                if (input == 1)
                {
                    RockPlayer Serena = new RockPlayer();
                    Console.WriteLine("You are playing against Serena Williams!");
                    int RockHand = Serena.generateRoshambo();
                    int User     = Yourself.generateRoshambo();
                    Console.WriteLine($"Serena picks {(Roshambo)RockHand} & Your pick is {(Roshambo)User}");


                    if ((Roshambo)RockHand == (Roshambo)User)
                    {
                        Console.WriteLine("***Draw!***");
                    }
                    else if (RockHand == 0 && User == 1)
                    {
                        Console.WriteLine("***Yay! You Win***");
                    }
                    else if (RockHand == 0 && User == 2)
                    {
                        Console.WriteLine("Sorry! You lose!");
                    }
                }
                else if (input == 2)
                {
                    RandomPlayer David = new RandomPlayer();
                    Console.WriteLine("You are playing against David Beckham!");
                    int ComputerHand = David.generateRoshambo();
                    int User         = Yourself.generateRoshambo();

                    Console.WriteLine($"David picks {(Roshambo)ComputerHand} & Your pick is {(Roshambo)User}");


                    if ((Roshambo)ComputerHand == (Roshambo)User)
                    {
                        Console.WriteLine("***Draw!***");
                    }
                    else if (ComputerHand == 0 && User == 1)
                    {
                        Console.WriteLine("***Yay! You win.***");
                    }
                    else if (ComputerHand == 0 && User == 2)
                    {
                        Console.WriteLine("Sorry! You lose!");
                    }
                    else if (ComputerHand == 1 && User == 2)
                    {
                        Console.WriteLine("***Yay! You win.***");
                    }
                    else if (ComputerHand == 1 && User == 0)
                    {
                        Console.WriteLine("Sorry! You lose!");
                    }
                }
                else
                {
                    Console.WriteLine("Sorry. That was not invalid input. Please enster 1, 2 or 3.");
                    continue;
                }
            }
        }