示例#1
0
        static void Main(string[] args)
        {
            bool run = true;

            while (run == true)
            {
                Console.WriteLine("Welcome to Rock, Paper, Scissors!");


                RPSGenerator rps = new RPSGenerator();
                Rockstar     r   = new Rockstar(rps);
                Randy        ra  = new Randy(rps);
                RPSApp       app = new RPSApp(rps);

                Console.WriteLine(app);

                Console.WriteLine(app.GameOn());



                Console.WriteLine();

                run = Continue();
            }
        }
示例#2
0
        public RPSApp(RPSGenerator rps)
        {
            Console.Write("Enter your name: ");
            string name = Console.ReadLine();

            name = name.ToLower();
        }
示例#3
0
        public string GameOn()
        {
            Console.WriteLine("Who would you like to play against, Lenny or Randy?");

            string players = Console.ReadLine();

            players = players.ToLower();

            if (players == "randy")
            {
                RPSGenerator rps = new RPSGenerator();
                Randy        ra  = new Randy(rps);
                Console.WriteLine(ra.GenerateRPS());
            }
            else if (players == "lenny")
            {
                RPSGenerator rps = new RPSGenerator();
                Rockstar     r   = new Rockstar(rps);
                Console.WriteLine(r.GenerateRPS());
            }
            else
            {
                Console.WriteLine("That is not a valid player.");
            }

            Console.WriteLine("Rock, Paper or Scissors? R/P/S");
            string gameAnswer = Console.ReadLine();

            gameAnswer = gameAnswer.ToLower();


            /*if (name == "r" && players == "paper")
             * {
             *  Console.WriteLine(name + ": rock");
             *  Console.WriteLine(players + ": paper");
             *  Console.WriteLine(name + "wins!");
             * }
             * if (name == "p" && players == "paper")
             * {
             *  Console.WriteLine(name + ": paper");
             *  Console.WriteLine(players + ": paper");
             *  Console.WriteLine("Issa draw!");
             * }
             * if (name == "s" && players == "paper")
             * {
             *  Console.WriteLine(name + ": scissors");
             *  Console.WriteLine(players + ": paper");
             *  Console.WriteLine(players+ "wins!");
             * }*/

            return(players);
        }
示例#4
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);
        }
示例#5
0
文件: Program.cs 项目: anelguel/Lab12
        static void Main(string[] args)
        {
            bool run = true;

            while (run == true)

            {
                RPSGenerator rps = new RPSGenerator();
                Rock         r   = new Rock(rps);
                Weapon       w   = new Weapon(rps);



                Console.WriteLine("Enter your name");
                string inputName = Console.ReadLine();
                Console.WriteLine("Would you like to play against TheJets or the TheSharks? (j/s)");
                string inputPlayer = Console.ReadLine();
                inputPlayer = rps.JetsSharks(inputPlayer);
                Console.WriteLine("Rock, paper, or scissors? r/p/s");
                string inputWeapon  = rps.GetByString(Console.ReadLine());
                string randomWeapon = w.GenerateRPS();



                if (inputPlayer == "TheJets") //if user input is the JETS
                {
                    Console.WriteLine(inputName + ":" + inputWeapon + "\n" + inputPlayer + ":" + r.GenerateRPS());
                }
                else if (inputPlayer == "TheSharks")//if user input is the SHARKS
                {
                    Console.WriteLine(inputName + ":" + inputWeapon + "\n" + inputPlayer + ":" + randomWeapon);
                }


                run = Continue();
            }
        }
示例#6
0
 public Randy(RPSGenerator ra) : base(ra)
 {
     name = "Randy";
 }
示例#7
0
 public Rock(RPSGenerator r) : base(r) //this class will always spit out Rock??
 {
     name = "rock";
 }
示例#8
0
 public Rocky(RPSGenerator r) : base(r)
 {
     name = "Rocky";
 }
示例#9
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);
        }
示例#10
0
文件: Weapon.cs 项目: anelguel/Lab12
 public Weapon(RPSGenerator r) : base(r)
 {
     name = "rock";
     name = "paper";
     name = "scissors";
 }
示例#11
0
 public Player(RPSGenerator r)
 {
     rpsList = r;
 }
示例#12
0
 public Rockstar(RPSGenerator r) : base(r)
 {
     name = "Lenny";
 }
示例#13
0
 public Other(RPSGenerator r) : base(r)
 {
     name = "Others";
 }