-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLine.java
More file actions
53 lines (41 loc) · 1.21 KB
/
Copy pathLine.java
File metadata and controls
53 lines (41 loc) · 1.21 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
package subway.domain;
import java.util.ArrayList;
import java.util.List;
public class Line {
private static final String ERROR_STATION_MESSAGE = "[ERROR] 해당 노선에 없는 역입니다.";
private String name;
private List<Station> stations = new ArrayList<>();
public Line(String name) {
this.name = name;
}
public String getName() {
return name;
}
// 異붽� 湲곕뒫 援ы쁽
public void startStation(Station station) {
stations.add(station);
}
public void endStation(Station station) {
stations.add(stations.size(), station);
}
public void addStation(StationRepository stationRepository, String name, int count) {
Station station = stationRepository.findStation(name);
stations.add(count - 1, station);
}
public void viewLine() {
System.out.println("[INFO] " + name);
System.out.println("[INFO] " + "---");
for (int station = 0; station < stations.size(); station++) {
System.out.println("[INFO] " + stations.get(station).getName());
}
}
public void deleteStation(String name) {
for (int count = 0; count < stations.size(); count++) {
if (stations.get(count).equals(name)) {
stations.remove(count);
return;
}
}
System.out.println(ERROR_STATION_MESSAGE);
}
}