The following code works.
note changes to input you declare input both inside and outside of main, so the one initialised inside main is not available to the rest of the class, the one outside main stays unintialised
so replace
Scanner input = new Scanner(System.in);
with
input = new Scanner(System.in);
You were also setting input to null just before the second data input( the 1 or 2 choice). Just delete that line it is not wanted.
Be safe, be sage
import java.util.Scanner;
public class GameInterface {
static Scanner input;
public static void main(String args[]){
input = new Scanner(System.in);
GameInterface.printIntroMessage();
int choice = input.nextInt();
if(GameInterface.CheckIsValid(choice, 3)){
if( GameInterface.AskforConfirm(choice) ) {
System.out.println("Destination Has Been Reached!!!!!");
}
}
}//end method
//Prints a the game's first message to the user.
private static void printIntroMessage(){
System.out.println("Welcome to Aiur, what would you like to do?");
System.out.println("1. Explore Aiur.");
System.out.println("2. Recall a personality.");
System.out.println("3. Live in Aiur.");
}//end method
//This method checks to see if the given choice is actually allowed (a
//choice of 5 when there are 3 choices would not be allowed, for example)
//TRUE means the choice is valid, FALSE means the choice is invalid
private static boolean CheckIsValid(int SelectedChoice, int NumOfChoices){
int choice = SelectedChoice;
if(choice > 0 && choice < NumOfChoices + 1){
return true;
}else{
System.out.println("You have selected an invalid choice, choose again.");
return false;
}//end if/else
}//end method
//This method is intended to be used when risky or important decisions are made.
//It asks the user if they wish to go through with their decision.
//TRUE means the choice is the one wanted, FALSE means the choice is not the one wanted
private static boolean AskforConfirm(int SelectedChoice){
int choice = SelectedChoice;
System.out.println("You have chosen: " + choice);
System.out.println("Is this your final choice?");
System.out.println("1. yes");
System.out.println("2. no");
String nextinput = input.next();
int confirm = Integer.parseInt(nextinput);
//DID THE USER GIVE A 1 OR 2 IN RESPONSE?
if( GameInterface.CheckIsValid(confirm,2) ) { //the user did give a good response
if(confirm == 1){
return true;
}else{
return false;
}
}else{ //the user did NOT give a good response
System.out.println("You must supply a '1' or '2' to answer this question.");
System.out.println("I will ask again:");
return GameInterface.AskforConfirm(choice);
}
}
}//end class