Example #1
0
        static void Main(string[] args)
        {
            RPSGenerator rps   = new RPSGenerator();
            Rocky        r     = new Rocky(rps);
            var          rocky = r.GenerateRPS();
            Other        o     = new Other(rps);
            var          other = o.GenerateRPS();
            Console      c     = new Console();
            Score        sc    = new Score();

            int[] track = new int[2];

            var userName = c.GetUserName();

            bool run = true;

            while (run == true)
            {
                var playerName    = c.GetPlayer();                    //Rocky or Others
                var userChoiceRPS = c.GetRPSfromUser();               //r/p/s

                var human = rps.GetByString(userChoiceRPS.ToLower()); // Compares user string against the list (r/p/s) stored in RPSGenerator class

                if (playerName == "r")
                {
                    System.Console.WriteLine("Rocky: " + rocky); // rocky
                }
                else if (playerName == "o")
                {
                    System.Console.WriteLine("Other: " + other); // other
                }
                else
                {
                    System.Console.WriteLine("I did not understand that, please try again.");
                }

                System.Console.WriteLine(userName + " : " + human);              // user player

                track = sc.ScoreCard(rocky, other, human, userName, playerName); //integer array "track" keeps scores
                run   = Continue();
            }
            Score.DisplayScore(track, userName);
        }
Example #2
0
        public int[] ScoreCard(string _rocky, string _other, string _human, string _userName, string _playerName)
        {
            RPSGenerator rps = new RPSGenerator();
            Rocky        ro  = new Rocky(rps);
            Other        ot  = new Other(rps);

            if (_playerName == "r")
            {
                //Draw
                if (_human == _rocky)
                {
                    System.Console.WriteLine("Draw!");
                }
                //Paper beats rock
                else if (_human == "paper")
                {
                    winCountUser++;
                    System.Console.WriteLine(_userName + " :wins!"); // user wins
                }
                //Rock beats scissors
                else if (_human == "scissors")
                {
                    winCountRocky++;
                    System.Console.WriteLine(ro.GetName() + " :wins!"); // rocky wins
                }
            }

            if (_playerName == "o")
            {
                //Draw
                if (_human == _other)
                {
                    System.Console.WriteLine("Draw!");
                }
                //paper beats rock
                else if (_human == "paper" && _other == "rock")
                {
                    winCountUser++;
                    System.Console.WriteLine(_userName + " :wins!");// user wins
                }
                else if (_human == "rock" && _other == "paper")
                {
                    winCountOthers++;
                    System.Console.WriteLine(ot.GetName() + " :wins!");//others win
                }
                //rock beats scissors
                else if (_human == "rock" && _other == "scissors")
                {
                    winCountUser++;
                    System.Console.WriteLine(_userName + " :wins!"); // user wins
                }
                else if (_human == "scissors" && _other == "rock")
                {
                    winCountOthers++;
                    System.Console.WriteLine(ot.GetName() + " :wins!");//other wins
                }
                //scissors beat paper
                else if (_human == "scissors" && _other == "paper")
                {
                    winCountUser++;
                    System.Console.WriteLine(_userName + " :wins!");//user wins
                }
                else if (_human == "paper" && _other == "scissors")
                {
                    winCountOthers++;
                    System.Console.WriteLine(ot.GetName() + " :wins!");//other wins
                }
            }
            scoreBoard[0] = winCountUser;
            scoreBoard[1] = winCountRocky;
            scoreBoard[2] = winCountOthers;
            return(scoreBoard);
        }