-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLine.java
More file actions
52 lines (42 loc) · 1.26 KB
/
Copy pathLine.java
File metadata and controls
52 lines (42 loc) · 1.26 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
49
50
51
52
package subway.domain.line;
import subway.domain.station.Station;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class Line {
private final String name;
private final List<Station> stationList;
public Line(String name, List<Station> stationList) {
this.name = name;
this.stationList = stationList;
}
public String getName() {
return name;
}
public static Line getLine(String lineName, Station startStation, Station endStation) {
if (LineCheck.checkLineNameLength(lineName) && LineCheck.checkLineNameEndPoint(lineName)) {
}
return new Line(lineName, Arrays.asList(startStation, endStation));
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Line line = (Line) o;
return Objects.equals(name, line.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
public boolean contains(Station station) {
return stationList.contains(station);
}
public void insertSection(int index, Station station) {
stationList.add(index, station);
}
}