-
Notifications
You must be signed in to change notification settings - Fork 274
Expand file tree
/
Copy pathSubwayController.java
More file actions
75 lines (68 loc) · 2.21 KB
/
SubwayController.java
File metadata and controls
75 lines (68 loc) · 2.21 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
65
66
67
68
69
70
71
72
73
74
75
package Controller;
import subway.domain.Line;
import subway.domain.LineRepository;
import subway.domain.Station;
import java.util.List;
import java.util.Scanner;
public class SubwayController {
private static String userInput;
public SubwayController(Scanner scanner) {
run(scanner);
}
public static void run(Scanner scanner) {
System.out.println("## 메인 화면\n" +
"1. 역 관리\n" +
"2. 노선 관리\n" +
"3. 구간 관리\n" +
"4. 지하철 노선도 출력\n" +
"Q. 종료\n" +
"\n" +
"## 원하는 기능을 선택하세요.");
userInput = scanner.nextLine();
mainSelect(scanner);
}
private static void mainSelect(Scanner scanner) {
boolean inputCheck = false;
if (userInput.equals("1")) {
inputCheck = true;
StationController.runStationController(scanner);
run(scanner);
}
if (userInput.equals("2")) {
inputCheck = true;
LineController.runLineController(scanner);
run(scanner);
}
if (userInput.equals("3")) {
inputCheck = true;
SectionController.runSectionController(scanner);
run(scanner);
}
if (userInput.equals("4")) {
inputCheck = true;
printSubway();
run(scanner);
}
if (userInput.equals("Q")) {
inputCheck = true;
scanner.close();
}
if (inputCheck == false) {
System.out.println("[ERROR] 올바른 번호를 입력해주세요");
run(scanner);
}
}
private static void printSubway() {
System.out.println("## 지하철 노선도");
List<Line> lines = LineRepository.lines();
for (Line line : lines) {
System.out.println("[INFO] " + line.getName());
System.out.println("[INFO] ---");
List<Station> stations = line.getSection();
for (Station station : stations) {
System.out.println("[INFO] " + station.getName());
}
System.out.println();
}
}
}