Esempio n. 1
0
        public static void ComputerPlaysGuessMyNumber(int start, int end)
        {
            int    computerGuess = RandomNumberHelper.BisectionNumberGenerator(start, end);
            string yesOrNo;

            Console.WriteLine($"Is your number {computerGuess}?");
            Console.WriteLine("Select y or n:");
            yesOrNo = Console.ReadLine().ToLower();

            if (yesOrNo is "y")
            {
                Console.WriteLine("Beep Boop. I did it!");
            }
            else
            {
                Console.WriteLine("Is your number:\n1. Higher\n2. Lower?");
                string userInput        = Console.ReadLine();
                int    userInputInteger = Int32.Parse(userInput);

                if (userInputInteger == 1)
                {
                    ComputerPlaysGuessMyNumber(computerGuess + 1, end);
                }
                else
                {
                    ComputerPlaysGuessMyNumber(start, computerGuess - 1);
                }
            }
        }
Esempio n. 2
0
        public static void HumanPlays()
        {
            Console.WriteLine("Guess the computer's number!\n");
            RandomNumberHelper.RandomNumberGenerator();
            ArrayHelper.ArrayGenerator(1, 1000);
            Console.WriteLine("The computer has chosen a number.\n");
            Console.WriteLine("What is your guess between 1 and 1000?\n");
            string humanInput        = Console.ReadLine();
            int    humanInputInteger = Int32.Parse(humanInput);

            Program.HumanPlaysGuessMyNumber(humanInputInteger);
        }