Java Method Adventure

Your task:

Create a very simple text adventure game.

Requirements:

  • Game has at least three areas.
  • Write a method for each area.
  • Each method prints a description of the area when it is called.
  • Each method gives the player some choices and uses a Scanner to record their input.
  • If the player’s input isn’t one of the choices, the game tells the user to try again.
  • Each method either calls itself (to stay in the same area) or one of the other methods (to travel to a different area).

Suggestions:

You can create class variables (or objects) if you want to see the same variable form all of your methods. Make them static. Example:

class MyGame {

//class variables -- declare before your methods
static Scanner scan = new Scanner(System.in);
static int score = 0;

    public static void main(){
        //game code here
    }

}

Use if / else if / else statements to decide what method to call (i.e. what area the player is sent to).

Don’t use a series of separate if statements. This will cause some weird behavior when more than one of the if conditions is true.

Use String methods like contains() and equals() to check their answers.

You can use toLowerCase() to eliminate case sensitivity problems.