-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathApplication.java
More file actions
54 lines (45 loc) · 2.43 KB
/
Copy pathApplication.java
File metadata and controls
54 lines (45 loc) · 2.43 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;
import subway.domain.*;
import subway.screen.MainScreen;
import subway.screen.ScreenManager;
import subway.screen.ScreenModel;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
initialize();
ScreenManager.addNextMenuScreen(new MainScreen(scanner));
while (!ScreenManager.isEmpty()) {
try {
ScreenModel nextScreen = ScreenManager.pop();
ScreenManager.show(nextScreen);
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
ScreenManager.addNextMenuScreen(new MainScreen(scanner));
}
}
}
private static void initialize() {
List<Station> stations = Arrays.asList(new Station("교대역"), new Station("강남역")
, new Station("역삼역"), new Station("남부터미널역"), new Station("양재역")
, new Station("양재시민의숲역"), new Station("매봉역"));
stations.stream().forEach(station -> StationRepository.addStation(station));
List<Line> lines = Arrays.asList(new Line("2호선").addTerminus("교대역", "역삼역")
, new Line("3호선").addTerminus("교대역", "매봉역")
, new Line("신분당선").addTerminus("강남역", "양재시민의숲역"));
lines.stream().forEach(line -> LineRepository.addLine(line));
SectionRepository.addSection("2호선", "강남역", 1);
SectionRepository.addSection("3호선", "남부터미널역", 1);
SectionRepository.addSection("3호선", "양재역", 2);
SectionRepository.addSection("신분당선", "양재역", 1);
SectionRepository.addSectinonDistanceAndTime("교대역", "강남역", 2, 3);
SectionRepository.addSectinonDistanceAndTime("강남역", "역삼역", 2, 3);
SectionRepository.addSectinonDistanceAndTime("교대역", "남부터미널역", 3, 2);
SectionRepository.addSectinonDistanceAndTime("남부터미널역", "양재역", 6, 5);
SectionRepository.addSectinonDistanceAndTime("양재역", "매봉역", 1, 1);
SectionRepository.addSectinonDistanceAndTime("강남역", "양재역", 2, 8);
SectionRepository.addSectinonDistanceAndTime("양재역", "양재시민의숲역", 10, 3);
}
}