Example #1
0
        private uint BestOfRequired()
        {
            var yesNoValidator = new YesNoValidator();

            while (!yesNoValidator.Validate(new UserChoice(userChoice)).IsValid)
            {
                Console.WriteLine("\nWould you like to play a \"best-of\" match?");
                string yesNo = Console.ReadLine();
                userChoice = yesNo.ToUpper();

                var message = yesNoValidator.Validate(new UserChoice(userChoice));
                Console.WriteLine(message);
            }

            var yesValidator = new YesValidator();

            if (yesValidator.Validate(new UserChoice(userChoice)).IsValid)
            {
                Console.WriteLine("How many rounds do you want to play?");
                while (!uint.TryParse(Console.ReadLine(), out this.bestOfCounter))
                {
                    Console.WriteLine("Please enter a positive number.");
                }
            }
            this.ClearUserChoice();
            return(bestOfCounter);
        }
Example #2
0
        private void Introduction()
        {
            Console.WriteLine("Welcome to Rock, Paper, Scissors!");
            var yesNoValidator = new YesNoValidator();

            while (!yesNoValidator.Validate(new UserChoice(userChoice)).IsValid)
            {
                Console.WriteLine("\nDo you need to read the instructions?");
                string instructions = Console.ReadLine();
                userChoice = instructions.ToUpper();

                var message = yesNoValidator.Validate(new UserChoice(userChoice));
                Console.WriteLine(message);

                var yesValidator = new YesValidator();
                if (yesValidator.Validate(new UserChoice(userChoice)).IsValid)
                {
                    this.Instructions();
                    break;
                }
            }
            this.ClearUserChoice();
        }