I want store on an enum classes, so later I can instantiate this class. But I don't know how I can do that.
This is an example:
public enum STATE {
MENU(Menu.class, Color bgColor);
PLAY(Play.class, Color bgColor);
...
public STATE() {...
}
}
and having a method for change between states. All the classes on STATE inherit from AState, So for example (public class Menu extends AState{...}
)
Astate currentState;
public void changeState(STATE s){
if(currentState != null) currentState.dispose();
currentState = ...some code to instantiate the class and assign to this value
currentState.init();
}
My idea is have an enum that holds the class for each state, and a few parameters to instantiate this class with different values like his bgColor, but I don't know how do this in Java.