예제 #1
0
        static void Main(string[] args)
        {
            string winner = "";
            string name   = "";
            int    num2   = 0;
            bool   player = true;
            bool   compU  = false;
            bool   repeat = false;

            RockPaperPlayer comp = new RockPaperPlayer("Watson");

            Greeting();
            name = GetName();
            RockPaperPlayer user = new RockPaperPlayer(name);

            do
            {
                for (int i = 1; i <= 7; i++)
                {
                    int number = GetNum(player);
                    user.MakeChoice(number);
                    num2 = GetNum(compU);
                    comp.MakeChoice(num2);

                    winner = PlayRound(user, comp);
                    Winner(user, comp, i, winner);
                }
                repeat    = RepeatGame();
                user.Wins = 0;
                comp.Wins = 0;
            } while (repeat == true);
        }
예제 #2
0
        public static void Winner(RockPaperPlayer user, RockPaperPlayer Watson, int round, string winner)
        {
            WriteLine("Round " + round);
            WriteLine(user.Name + " chose " + user.Choice);
            WriteLine(Watson.Name + " chose " + Watson.Choice);
            WriteLine();
            WriteLine(winner);
            WriteLine(user);
            WriteLine(Watson);
            WriteLine();

            if (round == 7)
            {
                if (user.Wins > Watson.Wins)
                {
                    WriteLine("Winner of the game is: " + user.Name);
                }
                else if (user.Wins < Watson.Wins)
                {
                    WriteLine("Winner of the game is: " + Watson.Name);
                }
                else
                {
                    WriteLine("Game was a Tie");
                }
            }
        }
예제 #3
0
        public static string PlayRound(RockPaperPlayer user, RockPaperPlayer Watson)
        {
            string winner = "";
            string player = user.Choice;
            string comp   = Watson.Choice;

            if (player == "rock" && comp == "rock")
            {
                winner = "Round was a Tie\n";
            }
            else if (player == "paper" && comp == "paper")
            {
                winner = "Round was a Tie\n";
            }
            else if (player == "scissors" && comp == "scissors")
            {
                winner = "Round was a Tie\n";
            }

            else if (player == "rock" && comp == "scissors")
            {
                winner     = "Winner is: " + user.Name;
                user.Wins += 1;
            }
            else if (player == "paper" && comp == "rock")
            {
                winner     = "Winner is: " + user.Name;
                user.Wins += 1;
            }
            else if (player == "scissors" && comp == "paper")
            {
                winner     = "Winner is: " + user.Name;
                user.Wins += 1;
            }

            else if (player == "paper" && comp == "scissors")
            {
                winner       = "Winner is: " + Watson.Name;
                Watson.Wins += 1;
            }
            else if (player == "scissors" && comp == "rock")
            {
                winner       = "Winner is: " + Watson.Name;
                Watson.Wins += 1;
            }
            else if (player == "rock" && comp == "paper")
            {
                winner       = "Winner is: " + Watson.Name;
                Watson.Wins += 1;
            }
            return(winner);
        }