I'm working on an assignment and I mostly have it finished but I am having an issue with the last method. I'm trying to write a `continueGame()` method that will ask the user if they want to continue to play, and accept "y" or "n". If answered "y", the program starts again. If answered "n", the program stops and a message is shown. The problem is I need it to trigger the `continueGame()` method only when `userChoice == answer`. This is a number guessing game with an object oriented approach.

I've tried to call the `continueGame()` method inside my `else if(userChoice == answer)` statement but it doesn't seem to work. Even when my other `if/else if` statements are triggered, it continues to the `continueGame()` method.

Here is the main driver for the game

```
import java.util.Scanner;

public class NumberGame
{
   public static void main(String[] args)
   {
      Scanner input = new Scanner (System.in);
      GameOptions opt = new GameOptions(); // Your created class
      int userChoice = -1234;
      int answer = -1234;
      boolean keepPlaying = true;

      System.out.println("Guess the Number Game\n");

      while (keepPlaying == true) {
         answer = (int) (Math.random() * 10)+1;

         //Create a getChoice method in your class and make sure it accepts a Scanner argument 
         userChoice = opt.getChoice(input);

         //Create a checkAnswer method in your class. Make sure it accepts two integer arguments and a Scanner argument
         opt.checkAnswer(userChoice, answer, input);

         // Create a continueGame method in  your class and make sure it accepts a Scanner argument
         keepPlaying = opt.continueGame(input);    
      } 
      System.out.println("Thanks for playing.");
   }
}

```

Here is the class that I am working on for the methods. Note that I can not make any modifications to the main driver file.

```
import java.util.InputMismatchException;
import java.util.Scanner;
import java.lang.NumberFormatException;

public class GameOptions {
    int count = 0;
    boolean cont = true;
    //getChoice Method for NumberGame
    public int getChoice(Scanner scnr) {

        System.out.println("Please choose a number between 1 and 10: ");
        int userGuess = 0;
        String input = scnr.next();
        try {
            userGuess = Integer.parseInt(input);
            if (userGuess < 1 || userGuess > 10) {
                throw new IllegalArgumentException("Invalid value. Please enter a number between 1 and 10: ");
            }
        }
        catch(NumberFormatException e) {
            System.out.println("Error - Enter Numerical Values Only");
            return userGuess;
        }
        catch (IllegalArgumentException ex) {
            System.out.println(ex.getMessage());
        }
        return Integer.parseInt(input);
    }

    public void checkAnswer(int userChoice, int answer, Scanner scnr) {
        if (userChoice > answer && userChoice < 11) {
            System.out.println("Too high. Try again.");
            count++;
        } else if (userChoice < answer && userChoice > 0) {
            System.out.println("Too low. Try again.");
            count++;
        } else if (userChoice == answer) {
            System.out.println("You got it! Number of tries: " + count);
            System.out.println("Would you like to play again? (y/n)");
        }
    }

    public static boolean continueGame(Scanner scnr) {

        String input = scnr.nextLine();
        if (input.toLowerCase().equals("y")){
            return true;
        } else if (input.toLowerCase().equals("n")){
            return false;
        } else {
            System.out.println("Invalid entry. Please enter either y or n: ");
            return continueGame(scnr);
        }
    }
}

```

So I should be able to enter a number, and if its lower than the answer it will tell me I am too low, if its higher than the answer it will tell me that its too high, if its equal it will tell me I won and prompt me to press "y" or "n" if I want to continue. Another issue I am running into is that I am getting "Would you like to play again? (y/n)" no matter whether I guess the right number or not and my only option is to hit "y" or "n"