예제 #1
0
        public int InputTarget(int length)
        {
            int target;

            Console.WriteLine($"Please enter a number between 1 and {length}");
            target = UtilityHandler.ErrorHandler(length);

            return(target);
        }
예제 #2
0
        public void LookForNumber(int[] arrList, int target)
        {
            int  userGuess;
            bool guessRight = false;
            int  counter    = 0;

            Console.WriteLine($"I have chosen a number between 1 and {arrList.Length}.  Let's see how quickly you can find it");
            Console.WriteLine("I'll tell you if your number is higher or lower than my number.");

            do
            {
                Console.WriteLine($"Enter a number between 1 and {arrList.Length}");
                userGuess = UtilityHandler.ErrorHandler(arrList.Length);

                guessRight = FindNumber(target, userGuess);
                counter++;
            } while (!guessRight);

            Console.WriteLine($"Congratulations! You found the correct number in {counter} guesses!");
            Console.ReadLine();
            Console.Clear();
        }