-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathMainDashboard.java
More file actions
64 lines (51 loc) · 1.73 KB
/
Copy pathMainDashboard.java
File metadata and controls
64 lines (51 loc) · 1.73 KB
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 subway.controller;
import static subway.SubwayKeyWords.*;
import java.util.TreeMap;
import subway.exceptions.ExceptionOptionUnavailable;
import subway.view.InputView;
import subway.view.OutputView;
public class MainDashboard {
public static String title = DASHBOARD_MAIN;
TreeMap<String, String> options;
InputView inputView;
boolean power;
public MainDashboard(InputView inputView) {
this.inputView = inputView;
power = true;
options = new TreeMap<>();
options.put(OPTION_NUM_1, DASHBOARD_MAIN_OPTION_1);
options.put(OPTION_QUIT, DASHBOARD_OPTION_Q);
startMainDashboard(inputView);
}
public void startMainDashboard(InputView inputView) {
while (power) {
String chosenOption = makeUserChooseOption(inputView);
startChosenOption(chosenOption);
}
}
public String makeUserChooseOption(InputView inputView) {
while (true) {
OutputView.showOptions(title, options);
String optionChosen = inputView.chooseOption();
try {
checkOptions(optionChosen);
return optionChosen;
} catch (ExceptionOptionUnavailable e) {
OutputView.showErrorMessage(e);
}
}
}
public void checkOptions(String input) throws ExceptionOptionUnavailable {
if (!options.containsKey(input)) {
throw new ExceptionOptionUnavailable();
}
}
public void startChosenOption(String option) {
if (option.equals(OPTION_NUM_1)) {
RouteDashboard routeDashboard = new RouteDashboard(inputView);
}
if (option.equals(OPTION_QUIT)) {
power = false;
}
}
}