-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLine.java
More file actions
45 lines (35 loc) · 1.04 KB
/
Copy pathLine.java
File metadata and controls
45 lines (35 loc) · 1.04 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.line;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import subway.domain.station.Station;
public class Line {
private final List<Station> stations = new ArrayList<>();
private String name;
public Line(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void addAllStation(List<Station> stationsList) {
stations.addAll(stationsList);
}
public void addStationByIndex(Station station, int index) {
stations.add(index, station);
}
public void deleteStationByName(String name) {
stations.removeIf(station -> station.getName().equals(name));
}
public boolean isContainsStation(Station station) {
for (Station each : stations) {
if (each.getName().equals(station.getName())) {
return true;
}
}
return false;
}
public List<Station> stations() {
return Collections.unmodifiableList(stations);
}
}