I have some classes that I want to initialize only if the passed parameter is true. It turns out that every implementaion of this method is the same, but is just used for a different class.
public static NamedScene getScene(boolean init) {
if (mainMenu == null) {
mainMenu = new MainMenu();
}
if (init) mainMenu.init();
return mainMenu;
}
I would like to abstract this method, so I won't have to access it manually via calling MainMenu.init(true);
but with scene.init(true);
where scene extends the abstract class.
There are some default properties for every class, like name that is acessed via the abstract method getName(). I expect the method to sometimes return the class instance without init(), and sometimes with init().