-
Notifications
You must be signed in to change notification settings - Fork 0
/
OptionsMenu.java
64 lines (47 loc) · 1.75 KB
/
OptionsMenu.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.company;
import java.util.HashMap;
import java.util.Scanner;
public class OptionsMenu {
CheckpointController controller = new CheckpointController();
public OptionsMenu() {
Scanner scanner = new Scanner(System.in);
HashMap<String, Runnable> options = new HashMap<>();
options.put("register",()->{
System.out.println("Please enter the address");
controller.registerAddress(scanner.next());
});
options.put("remove",()->{
System.out.println("Please enter the address");
controller.removeAddress(scanner.next());
});
options.put("request",()->{
System.out.println("Please enter the license plate and address");
controller.requestAccess(scanner.next(),scanner.next());
});
options.put("exit",()-> {
System.exit(0);
});
options.put("print--plate",()-> {
System.out.println(controller.getRegisteredPlates());
});
options.put("print--blacklist",()-> {
System.out.println(controller.getBlacklist());
});
options.put("print--addr",()-> {
System.out.println(controller.getAddresses());
});
while (true){
System.out.println("Please select one on the following\n" +
"register: register a new address\n" +
"remove: remove an adress\n" +
"request: request access\n" +
"exit: exit system");
String arg = scanner.next();
if (options.containsKey(arg)){
options.get(arg).run();
} else {
System.out.println("Invalid argument");
}
}
}
}