-
Notifications
You must be signed in to change notification settings - Fork 276
Expand file tree
/
Copy pathPathController.java
More file actions
37 lines (32 loc) · 1.11 KB
/
PathController.java
File metadata and controls
37 lines (32 loc) · 1.11 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
package subway.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import subway.domain.Path;
import subway.domain.PathType;
import subway.service.PathService;
import subway.view.InputView;
import subway.view.OutputView;
import utils.LineUtils;
public class PathController {
private static final List<String> EXIT_SIGN = Arrays.asList("b", "B");
private PathController() {
}
public static void pathSearch(Scanner scanner) {
OutputView.printMenu(LineUtils.PATH_MENU);
String selection = InputView.inputSelection(scanner);
executeSelection(scanner, selection);
}
private static void executeSelection(Scanner scanner, String selection) {
if (EXIT_SIGN.contains(selection)) {
return;
}
if (Integer.parseInt(selection) == PathType.DISTANCE.getNumber()) {
Path path = PathService.shortestDistancePath(scanner);
System.out.println(path.getDistance());
}
if (Integer.parseInt(selection) == PathType.TIME.getNumber()) {
PathService.shortestTimePath();
}
}
}