-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathStationRepository.java
More file actions
42 lines (34 loc) · 1.14 KB
/
Copy pathStationRepository.java
File metadata and controls
42 lines (34 loc) · 1.14 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
package subway.domain;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public class StationRepository {
private static final String INFO = "[INFO] ";
private static final String STATION_LIST = "## 역 목록";
private static final List<Station> stations = new ArrayList<>();
public static List<Station> stations() {
return Collections.unmodifiableList(stations);
}
public static void addStation(Station station) {
stations.add(station);
}
public static boolean deleteStation(String name) {
return stations.removeIf(station -> Objects.equals(station.getName(), name));
}
public static boolean isStationExist(String stationName) {
for (Station station : stations) {
if (station.isSameName(stationName)) {
return true;
}
}
return false;
}
public static void printStations() {
System.out.println();
System.out.println(STATION_LIST);
for (Station station : stations) {
System.out.println(INFO + station.getName());
}
}
}