-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathLine.java
More file actions
45 lines (36 loc) · 1.2 KB
/
Copy pathLine.java
File metadata and controls
45 lines (36 loc) · 1.2 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
package subway.domain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Line {
private String name;
private List<Station> stations = new ArrayList<Station>();
private List<Integer> distances = new ArrayList<Integer>(); // 0번째와 1번째 station들의 관계는 0번째 인덱스에
// 존재한다.
private List<Integer> times = new ArrayList<Integer>();
public Line(String name) {
this.name = name;
}
public String getName() {
return name;
}
public List<Station> getStations() {
return Collections.unmodifiableList(stations);
}
public List<Integer> getDistances() {
return Collections.unmodifiableList(distances);
}
public List<Integer> getTimes() {
return Collections.unmodifiableList(times);
}
public void registerFirstStation(Station station) {
if (stations.isEmpty()) {
stations.add(station);
}
}
public void pushSections(Station station, int distance, int time) {
stations.add(station);
distances.add(distance);
times.add(time);
}
}