-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathLine.java
More file actions
48 lines (38 loc) · 1.29 KB
/
Copy pathLine.java
File metadata and controls
48 lines (38 loc) · 1.29 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
package subway.domain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Line {
private String name;
private final List<Station> stationInLine = new ArrayList<>();
private final List<Integer> distanceInterval = new ArrayList<>();
private final List<Integer> timeInterval = new ArrayList<>();
public Line(String name, String[] stations, int[] distance, int[] time) {
this.name = name;
for (String station : stations) {
addStationInLine(StationRepository.findStationByName(station));
}
for (int i = 0; i < distance.length; i++) {
addDistanceInterval(distance[i]);
addTimeInterval(time[i]);
}
}
private void addStationInLine(Station station) {
stationInLine.add(station);
}
private void addDistanceInterval(int distance) {
distanceInterval.add(distance);
}
private void addTimeInterval(int time) {
timeInterval.add(time);
}
public void registerInterval() {
Interval.registerIntervals(stationInLine, distanceInterval, timeInterval);
}
public String getName() {
return name;
}
public List<Station> stationsInLine() {
return Collections.unmodifiableList(stationInLine);
}
}