package task3;

import java.util.Scanner;

public class NumberGuesserAI {
    private final int number;

    public NumberGuesserAI(int targetNumber){
        this.number = targetNumber;
    }
    public boolean isBigger(int guess){
        return guess < number;
    }

    public void autoGuess(){
        int low = Integer.MIN_VALUE;
        int high = Integer.MAX_VALUE;

        while (low <= high) {
            int mid = low + (high - low) / 2;

            if (mid == number) {
                System.out.println("Found the number: " + mid);
                return;
            } else if (isBigger(mid)) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
    }

    public static void main(String[] args) {
        NumberGuesserAI numberGuesser = new NumberGuesserAI(100);
        System.out.println(numberGuesser.isBigger(Integer.MAX_VALUE/2));
        numberGuesser.autoGuess();
    }
}