Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            bool repeat = true;

            while (repeat == true)
            {
                Roshambo      rps = new Roshambo();         //Roshambo object rps
                DwayneJohnson ro  = new DwayneJohnson(rps); //Dwayne Johnson object ro
                GrantThompson ra  = new GrantThompson(rps); //Grant Thompson object ra
                UserPlayer    uc  = new UserPlayer(rps);    //User object uc
                RoshamboApp   op  = new RoshamboApp();
                Console.WriteLine("Welcome to Rock, Paper, Scissors! Enter your name:");
                string userName = Console.ReadLine();
                Console.WriteLine("Thanks {0}! Would you like to play against {1} or {2} (DJ/GT)?", userName, ro.GetName(), ra.GetName());
                string userOpponent = op.OpponentName();
                Console.WriteLine("Your opponent is {0}. Rock, paper, or scissors (R/P/S)?", userOpponent);
                Console.WriteLine(userName + ": " + uc.GenerateRoshambo());
                if (userOpponent == "Dwayne Johnson")
                {
                    Console.WriteLine(ro.GetName() + ": " + ro.GenerateRoshambo()); //generate Roshambo using the method defined in the Dwayne Johnson class
                }
                if (userOpponent == "Grant Thompson")
                {
                    Console.WriteLine(ra.GetName() + ": " + ra.GenerateRoshambo()); //generate Roshambo using the method defined in the Grant Thompson class
                }
                repeat = DoAgain();
            }
            Console.WriteLine("Thanks for playing! Goodbye.");
        }
Ejemplo n.º 2
0
        public static void Play(UserPlayer userPlayer, Player choosenPlayer)
        {
            int i = 0;

            //int rockyWins = 0;
            //int randomWins = 0;
            //int ties = 0;

            while (i < 10)// this means we will run it 10 times.
            {
                Console.WriteLine("Pick Rock, Paper, Scissors");
                string rocky  = choosenPlayer.GenerateRoshambo();
                string random = userPlayer.GenerateRoshambo();

                if (rocky == "Rock" && random == "Rock")
                {
                    Console.WriteLine($"{userPlayer.Name} selected {random}");
                    Console.WriteLine(($"{choosenPlayer.Name} selected {rocky}"));
                    Console.WriteLine("Tie");
                }

                else if (rocky == "Rock" && random == "Paper")
                {
                    Console.WriteLine($"{userPlayer.Name} selected {random}");
                    Console.WriteLine(($"{choosenPlayer.Name} selected {rocky}"));
                    Console.WriteLine($"{choosenPlayer.Name} Wins!");
                }
                else if (rocky == "Rock" && random == "Scissors")
                {
                    Console.WriteLine($"{userPlayer.Name} selected {random}");
                    Console.WriteLine(($"{choosenPlayer.Name} selected {rocky}"));
                    Console.WriteLine($"{choosenPlayer.Name} Wins!");
                }
                else if (rocky == "Rock" && random == "Paper")
                {
                    Console.WriteLine($"{userPlayer.Name} selected {random}");
                    Console.WriteLine(($"{choosenPlayer.Name} selected {rocky}"));
                    Console.WriteLine($"{userPlayer.Name} Wins!");
                }
                i++;  // this is to get out of the while loop
            }
        }
Ejemplo n.º 3
0
        public void BeginRoshambo()
        {
            UserPlayer user = new UserPlayer();

            user.Name = Program.GetUserInput("Please enter your name.");
            bool goAgain = true;

            while (goAgain)
            {
                Console.Clear();
                Player opponent = ChooseOpponent();
                user.Roshambo = user.GenerateRoshambo();

                opponent.GenerateRoshambo();
                Console.WriteLine($"{opponent.ReturnName()} has thrown {opponent.GenerateRoshambo()}");
                Console.WriteLine($"{user.Name} has thrown {user.Roshambo}");
                if (user.Winner(opponent))
                {
                    Console.WriteLine($"{user.ReturnName()} is the winner!");
                }
                else if (opponent.Winner(user))
                {
                    Console.WriteLine($"{opponent.ReturnName()} is the winner!");
                }
                else
                {
                    Console.WriteLine("Tie! Nobody wins!");
                }

                string quitChoice;
                Console.WriteLine($"You have a total of {user.Wins()} wins, {user.Losses()} losses, and {user.Ties()} ties.");
                Console.WriteLine("Enter (Q)uit to exit, or any other key to run again");

                quitChoice = Console.ReadLine().Trim();

                if (quitChoice.ToLower() == "q" || quitChoice.ToLower() == "quit")
                {
                    goAgain = false;
                }
            }
        }