-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathLine.java
More file actions
36 lines (27 loc) · 830 Bytes
/
Copy pathLine.java
File metadata and controls
36 lines (27 loc) · 830 Bytes
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
package subway.domain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class Line {
private String name;
public Line(String name) {
this.name = name;
}
public String getName() {
return name;
}
// 추가 기능 구현
private List<Station> stationList = new ArrayList<>();
public List<Station> stations() {
return Collections.unmodifiableList(stationList);
}
public void addStation(String stationName) {
Station station = StationRepository.findStationByName(stationName);
station.addLine(this.name);
stationList.add(station);
}
public boolean deleteStation(String name) {
return stationList.removeIf(station -> station.getName().equals(name));
}
}