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

  1. package Application;
  2. public class MenuManager {
  3. private Menu rootMenu;
  4. private Menu currentMenu;
  5. public MenuManager(Menu rootMenu){
  6. this.rootMenu = rootMenu;
  7. this.currentMenu = rootMenu;
  8. }
  9. public void select(int i){
  10. this.currentMenu = currentMenu.getMenu(i);
  11. }
  12. public void back() throws Exception {
  13. if(!this.inRootMenu())
  14. this.currentMenu = this.currentMenu.getPreviousMenu();
  15. else
  16. throw new Exception("Menu is a root menu, a previous menu doesn't exist");
  17. }
  18. public Menu getCurrentMenu(){
  19. return this.currentMenu;
  20. }
  21. public boolean inRootMenu(){
  22. return this.currentMenu.equals(this.rootMenu);
  23. }
  24. }