-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLine.java
More file actions
57 lines (44 loc) · 1.11 KB
/
Copy pathLine.java
File metadata and controls
57 lines (44 loc) · 1.11 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
53
54
55
56
57
package subway.domain;
import subway.Constants;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Line {
private LineName name;
private List<Station> stations = new ArrayList<>();
public Line(LineName name) {
this.name = name;
}
public LineName getName() {
return name;
}
public void addStations(Station station) {
station.setRegister(true);
stations.add(station);
}
@Override
public boolean equals(Object object) {
if (object instanceof Line) {
Line anotherStation = (Line) object;
return name.equals(anotherStation.name);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public String toString() {
return Constants.INFORMATION + name;
}
public List<Station> getStations() {
return stations;
}
public int size() {
return stations.size();
}
public void addStations(int index, Station station) {
stations.add(index, station);
}
}