code for Load game (one of the working states) is exactly the same as all the broken ones, minus the class name
all broken state classes and Loadgame class return getID() == 3
.
in Game
constructor only Loadgame
is registered as state with id == 3
- the others are ignored and thus never registered.
then in initStatesList()
other state classes cannot be found because there were no states registered with ids like 4, 5, 6, 7
.
fix all the broken state classes (including Loadgame) as follows:
public class Newgame extends BasicGameState{ private int state; // !!!
public Newgame(int state){
this.state = state; // !!!
}
...
public int getID(){
return this.state; // !!!
}
}