-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathMainController.java
More file actions
50 lines (40 loc) · 1.3 KB
/
Copy pathMainController.java
File metadata and controls
50 lines (40 loc) · 1.3 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
package subway.controller;
import subway.domain.CommandType;
import subway.view.InputView;
import subway.view.OutputView;
import java.util.Scanner;
public class MainController {
private final InputView inputView;
private final PathController pathController;
public MainController(Scanner scanner) {
this.inputView = new InputView(scanner);
this.pathController = new PathController(inputView);
}
public void run() {
OutputView.printMainScreen(CommandType.getInfos());
CommandType commandType = requestCommandNumber();
while (isRunning(commandType)) {
runDetailAction();
OutputView.printMainScreen(CommandType.getInfos());
commandType = requestCommandNumber();
}
}
private CommandType requestCommandNumber() {
CommandType commandType = CommandType.EXIT;
while(true) {
try {
commandType = inputView.inputCommandNumber();
break;
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
return commandType;
}
private boolean isRunning(CommandType commandType) {
return !commandType.isExit();
}
private void runDetailAction() {
pathController.run();
}
}