コード例 #1
0
        static void Main(string[] args)
        {
            Player challenger = null;
            Player rock       = new Rockdummy();
            Player random     = new Randomdummy();

            int userNum = Validator.CheckRange(Validator.GetUserInput("Who would you like to challenge? \t1.Fingerless Fred\t2.Rando Randy"), 1, 2);

            if (userNum == 1)
            {
                challenger = rock;
            }
            if (userNum == 2)
            {
                challenger = random;
            }

            Console.WriteLine(RoshamboApp.Play(challenger, "Faten"));
            Console.WriteLine($"{challenger.Name} chose {challenger.Decision}");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            User user         = new User(GetUserInput("Enter your name: "));
            bool continueLoop = true;

            while (continueLoop)
            {
                RoshamboApp rockPaperScissors = new RoshamboApp();
                Console.Write("Select an enemy, rocky/randy: ");
                rockPaperScissors.SelectEnemy();

                Console.Write("Player 1: rock, paper or scissors?: ");
                Roshambo p1Attack = user.GenerateRoshambo();
                Roshambo p2Attack = rockPaperScissors.enemySelection.Attack;
                Console.WriteLine($"Enemy threw: {Enum.GetName(typeof(Roshambo), p2Attack)}");
                string result = EvaluateMatch(p1Attack, p2Attack);

                Console.WriteLine(result);
            }
        }