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

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

            return(target);
        }
예제 #2
0
        public void SearchNum(int[] arr, int target)
        {
            int  guess;
            bool right   = false;
            int  counter = 0;

            Console.WriteLine($"Can you guess my number??? lets see.");
            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 {arr.Length}");
                guess = UtilityHandler.ErrorHandler(arr.Length);

                right = FindNumber(target, guess);
                counter++;
            } while (!right);

            Console.WriteLine($"Good job it only took you {counter} guesses!");
            Console.ReadLine();
            Console.Clear();
        }