protected int readInt(int min, int max) {
        int result = min - 1;
        while (result < min || result > max) {
            try {
                result = scanner.nextInt();
                if (result > max || result < min) System.out.println(TRY_AGAIN_MSG);
            } catch (InputMismatchException ex) {
                scanner.nextLine();
                System.out.println(TRY_AGAIN_MSG);
                result = min - 1;
            }
        }
        return result;
    }