예제 #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 {0}", round);
            WriteLine(user.Name + " chose " + user.Choice);
            WriteLine(Watson.Name + " chose " + Watson.Choice);
            WriteLine();
            WriteLine(winner);
            WriteLine(user.ToString());
            WriteLine(Watson.ToString());
            WriteLine();

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

            //Start ties
            if (hooman == "rock" && comp == "rock")
            {
                winner = ("Round was a Tie\n");
            }
            else if (hooman == "paper" && comp == "paper")
            {
                winner = ("Round was a Tie\n");
            }
            else if (hooman == "scissors" && comp == "scissors")
            {
                winner = ("Round was a Tie\n");
            }
            //End of ties

            //Start player wins
            else if (hooman == "rock" && comp == "scissors")
            {
                winner     = string.Format("Winner is: {0}", user.Name);
                user.Wins += 1;
            }
            else if (hooman == "paper" && comp == "rock")
            {
                winner     = string.Format("Winner is: {0}", user.Name);
                user.Wins += 1;
            }
            else if (hooman == "scissors" && comp == "paper")
            {
                winner     = string.Format("Winner is: {0}", user.Name);
                user.Wins += 1;
            }
            //End player wins

            //sStart comp wins
            else if (hooman == "paper" && comp == "scissors")
            {
                winner       = string.Format("Winner is: {0}", Watson.Name);
                Watson.Wins += 1;
            }
            else if (hooman == "scissors" && comp == "rock")
            {
                winner       = string.Format("Winner is: {0}", Watson.Name);
                Watson.Wins += 1;
            }
            else
            {
                winner       = string.Format("Winner is: {0}", Watson.Name);
                Watson.Wins += 1;
            }
            //End compputer wins
            return(winner);
        }