-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathInitData.java
More file actions
41 lines (36 loc) · 1.78 KB
/
Copy pathInitData.java
File metadata and controls
41 lines (36 loc) · 1.78 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
package subway.init;
import subway.domain.Line;
import subway.domain.LineRepository;
import subway.domain.Station;
import subway.domain.StationRepository;
public class InitData {
final static String stationNames[] = {"교대역", "강남역", "역삼역", "남부터미널역", "양재역", "양재시민의숲역", "매봉역"};
final static String lineNames[] = {"2호선", "3호선", "신분당선"};
public static void startInitWork() {
createStationAndLine();
enrollStationToLine();
}
private static void createStationAndLine() {
for (String stationName : stationNames) {
StationRepository.addStation(new Station(stationName));
}
for (String lineName : lineNames) {
LineRepository.addLine(new Line(lineName));
}
}
private static void enrollStationToLine() {
final Line line1 = LineRepository.findByName(lineNames[0]).get();
line1.add(StationRepository.findByName(stationNames[0]).get());
line1.add(StationRepository.findByName(stationNames[1]).get());
line1.add(StationRepository.findByName(stationNames[2]).get());
final Line line2 = LineRepository.findByName(lineNames[1]).get();
line2.add(StationRepository.findByName(stationNames[0]).get());
line2.add(StationRepository.findByName(stationNames[3]).get());
line2.add(StationRepository.findByName(stationNames[4]).get());
line2.add(StationRepository.findByName(stationNames[6]).get());
final Line line3 = LineRepository.findByName(lineNames[2]).get();
line3.add(StationRepository.findByName(stationNames[1]).get());
line3.add(StationRepository.findByName(stationNames[4]).get());
line3.add(StationRepository.findByName(stationNames[5]).get());
}
}