You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
732 B
32 lines
732 B
package Application;
|
|
|
|
public class MenuManager {
|
|
|
|
private Menu rootMenu;
|
|
private Menu currentMenu;
|
|
|
|
public MenuManager(Menu rootMenu){
|
|
this.rootMenu = rootMenu;
|
|
this.currentMenu = rootMenu;
|
|
}
|
|
|
|
public void select(int i){
|
|
this.currentMenu = currentMenu.getMenu(i);
|
|
}
|
|
|
|
public void back() throws Exception {
|
|
if(!this.inRootMenu())
|
|
this.currentMenu = this.currentMenu.getPreviousMenu();
|
|
else
|
|
throw new Exception("Menu is a root menu, a previous menu doesn't exist");
|
|
}
|
|
|
|
public Menu getCurrentMenu(){
|
|
return this.currentMenu;
|
|
}
|
|
|
|
public boolean inRootMenu(){
|
|
return this.currentMenu.equals(this.rootMenu);
|
|
}
|
|
|
|
}
|