-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuBuilder.java
25 lines (19 loc) · 981 Bytes
/
MenuBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class MenuBuilder {
public static void demo() {
Menu demoMenu = new Menu("Demo Menu");
Menu subMenu = new Menu("Sub Menu");
demoMenu.addItem(new MenuItem("OpenSubMenu", subMenu::display ));
demoMenu.addItem(new MenuItem("Option 2", MenuBuilder::veryImportantFunc));
demoMenu.addItem(new MenuItem("Option 3", () -> System.out.println("Option 3 was selected")));
subMenu.addItem(new MenuItem("Sub Option 1", () -> System.out.println("Sub Option 1 was selected")));
subMenu.addItem(new MenuItem("Sub Option 2", () -> System.out.println("Sub Option 2 was selected")));
subMenu.addItem(new MenuItem("Sub Option 3", () -> System.out.println("Sub Option 3 was selected")));
demoMenu.display();
}
public static void veryImportantFunc() {
System.out.println("Very important function is completed");
}
public static void main(String[] args) {
MenuBuilder.demo();
}
}