-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathPathController.java
More file actions
54 lines (45 loc) · 1.72 KB
/
Copy pathPathController.java
File metadata and controls
54 lines (45 loc) · 1.72 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
package subway.controller;
import subway.graph.DistanceWeightedGraph;
import subway.graph.TimeWeightedGraph;
import subway.util.Validator;
import subway.view.InputView;
import subway.view.OutputView;
import java.util.Arrays;
import java.util.List;
public class PathController {
private final InputView inputView;
public PathController(InputView inputView) {
this.inputView = inputView;
}
private final List<String> buttons = Arrays.asList(
PathButton.SHORTEST_PATH.getSymbol(),
PathButton.LEAST_TIME.getSymbol(),
PathButton.BACK.getSymbol()
);
public void run() {
OutputView.printInquiry();
String selectedButton = inputView.getFunctionSelect(buttons);
nextProcedure(selectedButton);
}
private void nextProcedure(final String button) {
if (button.equals(PathButton.BACK.getSymbol())) {
return;
}
String source = inputView.getSourceStation();
String destination = inputView.getDestinationStation();
if (Validator.sameStation(source, destination)) {
nextProcedure(button);
return;
}
if (Validator.unconnected(source, destination)) {
nextProcedure(button);
return;
}
// 총 시간과 거리를 계산하는 함수를 구현하지 못했습니다.
if (button.equals(PathButton.SHORTEST_PATH.getSymbol())) {
OutputView.printInquiryGraph(DistanceWeightedGraph.getOptimalGraph(source, destination), -1, -1);
} else if (button.equals(PathButton.LEAST_TIME.getSymbol())) {
OutputView.printInquiryGraph(TimeWeightedGraph.getOptimalGraph(source, destination), -1, -1);
}
}
}