-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLine.java
More file actions
36 lines (28 loc) · 861 Bytes
/
Copy pathLine.java
File metadata and controls
36 lines (28 loc) · 861 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.List;
public class Line {
private String name;
public List<Station> stations = new ArrayList<Station>();
public Line(String name) {
this.name = name;
}
public Line(String name, Station... stations) {
this.name = name;
for(int i=0; i< stations.length; i++){
this.stations.add(stations[i]);
}
}
public String getName() {
return name;
}
public boolean existStation(String stationName) {
return stations.stream().anyMatch(s -> s.getName().equals(stationName));
}
public void addStation(String stationName, int order) {
stations.add(order-1, new Station(stationName));
}
public boolean checkStationSize() {
return stations.size() <= Constant.MIN_LENGTH;
}
}