I seem to have my scanner/Eclipse auto running user input. I have a scanner initialised as:
Scanner in = new Scanner(System.in);
with a menu as:
@Override
void update() {
//welcome
System.out.println("-----Welcome to the Pet Game-----");
System.out.println();
System.out.println("1. Play");
System.out.println("2. Help");
System.out.println("3. Dev Mode");
int choice = in.nextInt();
switch(choice){
case 1:
playLoop();
break;
case 2:
helpPage();
break;
case 3:
devMode();
break;
}
}
For some reason it is automatically inputting 2 on this menu. And follows with 3 on this menu:
// main menu
System.out.println("This is Day " + (i+1) + " you have " + dayActions + " Actions left.");
System.out.println("1. View Pet Status");
System.out.println("2. Shop");
System.out.println("3. Skip Action");
System.out.println("4. Play");
System.out.println("5. Feed");
System.out.println("6. Bathroom");
System.out.println("7. Sleep");
int choice = in.nextInt();
System.out.println();
I think this might be due to my GameState class but I am not sure. Gamestate class:
abstract class GameState {
abstract void update();
protected void pushState(GameState state) {
PetGame.pushState(state);
}
protected void popState() {
PetGame.popState();
}
}
StoreState (This is the class it is jumping to. I can't find any reference to it in my Code no idea why it is going here.)
public class StoreState{
@Override
void update() {
// TODO Auto-generated method stub
}
}
Thanks for your help.