From d3d9f1268920dc2912e2a75bdc16163269ed9f1a Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 17:33:04 +0900 Subject: [PATCH 01/23] =?UTF-8?q?docs:=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EB=AA=A9=EB=A1=9D=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md => docs/README.md | 88 +++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 18 deletions(-) rename README.md => docs/README.md (73%) diff --git a/README.md b/docs/README.md similarity index 73% rename from README.md rename to docs/README.md index 00410ae50..7e19bce63 100644 --- a/README.md +++ b/docs/README.md @@ -17,10 +17,10 @@ - 2호선: 교대역 - 강남역 - 역삼역 - 3호선: 교대역 - 남부터미널역 - 양재역 - 매봉역 - 신분당선: 강남역 - 양재역 - 양재시민의숲역 - ``` +``` + + - - ### 지하철 역 관련 기능 - 지하철 역을 등록하고 삭제할 수 있다. (단, 노선에 등록된 역은 삭제할 수 없다) - 중복된 지하철 역 이름이 등록될 수 없다. @@ -41,14 +41,14 @@ - 역과 역 사이에 새로운 역이 추가 될 수 있다. - 노선에서 갈래길은 생길 수 없다. - + ### 지하철 구간 삭제 기능 - 노선에 등록된 역을 제거할 수 있다. - 종점을 제거할 경우 다음 역이 종점이 된다. - 노선에 포함된 역이 두개 이하일 때는 역을 제거할 수 없다. - + ### 지하철 노선에 등록된 역 조회 기능 - 노선의 상행 종점부터 하행 종점까지 연결된 순서대로 역 목록을 조회할 수 있다. @@ -410,7 +410,7 @@ public class Application { - 제공하는 각 클래스의 기본 생성자를 추가할 수 없다. - 필드(인스턴스 변수)인 name의 접근 제어자 private을 변경할 수 없다. - 가능하면 setter 메소드(ex. setXXX)를 추가하지 않고 구현한다. - + ```java public class Station { private String name; @@ -434,7 +434,7 @@ public class Station { - 추가로 생성되는 객체에 대해서 XXXRepository 네이밍으로 저장 클래스를 추가할 수 있다. - 객체들의 상태를 관리하기 위해서 XXXRepository 클래스를 활용해 저장 로직을 구현해야 한다. - 필요에 따라 자유롭게 수정이 가능하다. - + ```java public class StationRepository { private static final List stations = new ArrayList<>(); @@ -455,15 +455,67 @@ public class StationRepository {
-## 📈 진행 요구사항 -- 미션은 [java-subway-map-precourse 저장소](https://github.com/woowacourse/java-subway-map-precourse) 를 fork/clone해 시작한다. -- 기능을 구현하기 전에 java-subway-map-precourse/docs/README.md 파일에 구현할 기능 목록을 정리해 추가한다. -- git의 commit 단위는 앞 단계에서 README.md 파일에 정리한 기능 목록 단위로 추가한다. - - [AngularJS Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153) 참고해 commit log를 남긴다. -- [프리코스 과제 제출 문서](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse) 절차를 따라 미션을 제출한다. - - [프리코스 과제 FAQ](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse/faq) 문서를 참고하여 진행할 수 있다. -
- -## 📝 License +## 📝 기능 구현 + +#### 1. 메인화면 + +- 메뉴에 있는 번호가 아니면 `[ERROR] 선택할 수 없는 기능입니다.` +- 메인 메뉴, 지하철 역 메뉴, 지하철 노선 메뉴, 지하철 구간 메뉴 생성 + +#### 2. 역 관리 + +- **역 등록** + - 지하철 역 등록하기 `[INFO] 지하철 역이 등록되었습니다.` + - 이름이 입력되지 않은 경우 `[ERROR] null값을 입력하셨습니다.` + - 이름은 2글자 이상이여야함 `[ERROR] 역이름은 2글자 이상 입력해야합니다.` + - `역`으로 끝나게 이름 작성해야함 `[ERROR] 역이름은 OO역으로 끝나야 합니다.` + - 중복되지 않도록 작성해야함 `[ERROR] 이미 등록된 역 이름입니다. 중복되지 않는 역이름을 입력해주세요.` +- **역 삭제** + - 지하철 역 삭제하기 `[INFO] 지하철 역이 삭제되었습니다.` + - 역 리스트에 존재해야함 `[ERROR] 존재하지 않는 역입니다.` + - 마지막에 `역`으로 끝나야함 `[ERROR] OO역으로 입력해야 삭제가 가능합니다.` + - 노선에 등록되어있지 않아야함 `[ERROR] 노선에 등록되어있는 역은 삭제가 불가능합니다.` +- **역 조회** + - 역 이름만 가지고 있는 배열 생성(조회하면 배열의 원소를 하나씩 보여주기) + +#### 3. 노선 관리 + +- **노선 등록** + - 노선 등록하기 `[INFO] 지하철 노선이 등록되었습니다.` + - 노선 이름 + - 이름은 2글자 이상이여야함 `[ERROR] 노선 이름은 2글자 이상 입력해야합니다.` + - `선`으로 끝나게 이름 작성해야함 `[ERROR] 노선이름은 OO선 또는 O호선으로 끝나야 합니다.` + - 중복되지 않도록 작성해야함 `[ERROR] 이미 존재하는 노선입니다. 중복되지 않는 노선 이름을 입력해주세요.` + - 상행 종점역 이름 / 하행 종점역 이름 + - 존재하는 역 중에서 작성해야함 `[ERROR] 존재하는 역 중에서 입력해주세요.` +- **노선 삭제** + - 지하철 노선 삭제하기 `[INFO] 지하철 노선이 삭제되었습니다.` + - 노선 리스트에 존재해야함 `[ERROR] 존재하지 않는 노선입니다.` + - 마지막에 `호선` 또는 `선`으로 끝나야함 `[ERROR] OO선 또는 O호선으로 입력해야합니다..` + - 노선에 등록되어있어야함 `[ERROR] 노선에 등록되어있지 않는 역입니다. 다시 입력해주세요.` +- **노선 조회** + - 노선 이름만 가지고 있는 배열 생성(조회하면 배열의 원소를 하나씩 보여주기) + +#### 4. 구간 관리 + +- **구간 등록** + - 구간 등록하기 `[INFO] 구간이 등록되었습니다.` + - 노선 이름 + - 존재하는 노선 중에서 작성해야함 `[ERROR] 존재하는 노선 중에서 입력해주세요.` + - 역 이름 + - 존재하는 역 중에서 작성해야함 `[ERROR] 존재하는 역 중에서 입력해주세요.` + - 순서 + - 종점 역 사이에 있어야함 `[ERROR] 종점역 사이에 존재해야합니다.` +- **구간 삭제** + - 지하철 노선 삭제하기 `[INFO] 지하철 노선이 삭제되었습니다.` + - 노선 리스트에 존재해야함 `[ERROR] 존재하지 않는 노선입니다.` + - 마지막에 `호선` 또는 `선`으로 끝나야함 `[ERROR] OO선 또는 O호선으로 입력해야합니다..` + - 노선에 등록되어있어야함 `[ERROR] 노선에 등록되어있지 않는 역입니다. 다시 입력해주세요.` + +#### 5. 지하철 노선도 출력 + +- 가지고 있어야하는 배열 + - 역만 가지고 있는 배열 + - 노선만 가지고 있는 배열 + - 노선도 -> [ [2호선, ---, 교대역, 강남역, 역삼역], [3호선, ---, ,,,], [신분당선, ---, ,,,] ] -This project is [MIT](https://github.com/woowacourse/java-subway-map-precourse/blob/master/LICENSE.md) licensed. From f177aa95484be2250fb5d2969579ce81137a1bd8 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 17:43:43 +0900 Subject: [PATCH 02/23] =?UTF-8?q?feat:=20=EB=A9=94=EC=9D=B8=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20inputView=EC=99=80=20outputView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subway/view/main/MainMenuInputView.java | 31 +++++++++++++++++++ .../subway/view/main/MainMenuOutputView.java | 15 +++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/main/java/subway/view/main/MainMenuInputView.java create mode 100644 src/main/java/subway/view/main/MainMenuOutputView.java diff --git a/src/main/java/subway/view/main/MainMenuInputView.java b/src/main/java/subway/view/main/MainMenuInputView.java new file mode 100644 index 000000000..8fedf76e3 --- /dev/null +++ b/src/main/java/subway/view/main/MainMenuInputView.java @@ -0,0 +1,31 @@ +package subway.view.main; + +import java.util.Scanner; + +public class MainMenuInputView { + + private static final String STATION_MENU = "1"; + private static final String LINE_MENU = "2"; + private static final String SECTION_MENU = "3"; + private static final String INVALID_INPUT = "[ERROR] 선택할 수 없는 기능입니다."; + private static final String QUIT_MENU = "Q"; + + public static String getMainMenuCommand(Scanner scanner) { + MainMenuOutputView.printMainMenu(); + try { + String menuCommand = scanner.nextLine(); + validateMainMenuCommand(menuCommand); + return menuCommand; + } catch (Exception e) { + System.out.println(e.getMessage()); + return getMainMenuCommand(scanner); + } + } + + private static void validateMainMenuCommand(String menuCommand) { + if (!menuCommand.equals(STATION_MENU) && !menuCommand.equals(LINE_MENU) && + !menuCommand.equals(SECTION_MENU) && !menuCommand.equals(QUIT_MENU)) { + throw new IllegalArgumentException(INVALID_INPUT); + } + } +} diff --git a/src/main/java/subway/view/main/MainMenuOutputView.java b/src/main/java/subway/view/main/MainMenuOutputView.java new file mode 100644 index 000000000..76c8c6e59 --- /dev/null +++ b/src/main/java/subway/view/main/MainMenuOutputView.java @@ -0,0 +1,15 @@ +package subway.view.main; + +public class MainMenuOutputView { + private static final String MAIN_MENU = "## 메인 화면\n1. 역관리\n2. 노선 관리\n3. 구간 관리\n4. 지하철 노선도 출력\nQ. 종료\n"; + private static final String CHOOSE_COMMAND_MESSAGE = "## 원하는 기능을 선택하세요."; + + public static void printMainMenu() { + System.out.println(MAIN_MENU); + printChooseCommandMessage(); + } + + public static void printChooseCommandMessage() { + System.out.println(CHOOSE_COMMAND_MESSAGE); + } +} \ No newline at end of file From dfcfe24c29cee85b82ceb137f9d8cb728c2875be Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 18:00:00 +0900 Subject: [PATCH 03/23] =?UTF-8?q?feat:=20Station=EB=A9=94=EB=89=B4=20input?= =?UTF-8?q?View=EC=99=80=20outputView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/Application.java | 4 +++ .../view/station/StationMenuInputView.java | 31 +++++++++++++++++++ .../view/station/StationMenuOutputView.java | 17 ++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/main/java/subway/view/station/StationMenuInputView.java create mode 100644 src/main/java/subway/view/station/StationMenuOutputView.java diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 0bcf786cc..3b2ac5ffe 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,10 +1,14 @@ package subway; +import subway.view.main.MainMenuInputView; +import subway.view.station.StationMenuInputView; + import java.util.Scanner; public class Application { public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); // TODO: 프로그램 구현 + System.out.println(StationMenuInputView.getStationMenuCommand(scanner)); } } diff --git a/src/main/java/subway/view/station/StationMenuInputView.java b/src/main/java/subway/view/station/StationMenuInputView.java new file mode 100644 index 000000000..dd1f9beeb --- /dev/null +++ b/src/main/java/subway/view/station/StationMenuInputView.java @@ -0,0 +1,31 @@ +package subway.view.station; + +import java.util.Scanner; + +public class StationMenuInputView { + + private static final String STATION_ENROLL_MENU = "1"; + private static final String STATION_DELETE_MENU = "2"; + private static final String STATION_PRINTALL_MENU = "3"; + private static final String INVALID_INPUT = "[ERROR] 선택할 수 없는 기능입니다."; + private static final String BACK_MENU = "B"; + + public static String getStationMenuCommand(Scanner scanner) { + StationMenuOutputView.printStation(); + try { + String stationMenuCommand = scanner.nextLine(); + validateStationMenuCommand(stationMenuCommand); + return stationMenuCommand; + } catch (Exception e) { + System.out.println(e.getMessage()); + return getStationMenuCommand(scanner); + } + } + + private static void validateStationMenuCommand(String stationMenuCommand) { + if (!stationMenuCommand.equals(STATION_ENROLL_MENU) && !stationMenuCommand.equals(STATION_DELETE_MENU) && + !stationMenuCommand.equals(STATION_PRINTALL_MENU) && !stationMenuCommand.equals(BACK_MENU)) { + throw new IllegalArgumentException(INVALID_INPUT); + } + } +} diff --git a/src/main/java/subway/view/station/StationMenuOutputView.java b/src/main/java/subway/view/station/StationMenuOutputView.java new file mode 100644 index 000000000..1ec9dbd01 --- /dev/null +++ b/src/main/java/subway/view/station/StationMenuOutputView.java @@ -0,0 +1,17 @@ +package subway.view.station; + +public class StationMenuOutputView { + + private static final String STATION_MENU = "## 역 관리 화면\n1. 역 등록\n2. 역 삭제\n3. 역 조회\nB. 돌아가기\n"; + private static final String CHOOSE_COMMAND_MESSAGE = "## 원하는 기능을 선택하세요."; + + public static void printStation() { + System.out.println(); + System.out.println(STATION_MENU); + printChooseCommandMessage(); + } + + public static void printChooseCommandMessage() { + System.out.println(CHOOSE_COMMAND_MESSAGE); + } +} From b89d6755d819ae008718bd04e5dbc01a2ff4497e Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 18:01:59 +0900 Subject: [PATCH 04/23] =?UTF-8?q?refactor:=20=EB=A9=94=EC=9D=B8=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20error=20message=ED=9B=84=20=ED=95=9C=20=EC=A4=84=20?= =?UTF-8?q?=EB=9D=84=EC=96=B4=20=EB=8B=A4=EC=8B=9C=20=EB=B3=B4=EC=9D=B4?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/view/main/MainMenuOutputView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/subway/view/main/MainMenuOutputView.java b/src/main/java/subway/view/main/MainMenuOutputView.java index 76c8c6e59..f54beac31 100644 --- a/src/main/java/subway/view/main/MainMenuOutputView.java +++ b/src/main/java/subway/view/main/MainMenuOutputView.java @@ -5,6 +5,7 @@ public class MainMenuOutputView { private static final String CHOOSE_COMMAND_MESSAGE = "## 원하는 기능을 선택하세요."; public static void printMainMenu() { + System.out.println(); System.out.println(MAIN_MENU); printChooseCommandMessage(); } From 4a0a3126ea65a803bff7177e3430c46bcfe567e8 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 18:07:13 +0900 Subject: [PATCH 05/23] =?UTF-8?q?feat:=20=EB=85=B8=EC=84=A0=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20inputView=EC=99=80=20outputView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subway/view/line/LineMenuInputView.java | 31 +++++++++++++++++++ .../subway/view/line/LineMenuOutputView.java | 17 ++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/java/subway/view/line/LineMenuInputView.java create mode 100644 src/main/java/subway/view/line/LineMenuOutputView.java diff --git a/src/main/java/subway/view/line/LineMenuInputView.java b/src/main/java/subway/view/line/LineMenuInputView.java new file mode 100644 index 000000000..bb8a3f123 --- /dev/null +++ b/src/main/java/subway/view/line/LineMenuInputView.java @@ -0,0 +1,31 @@ +package subway.view.line; + +import java.util.Scanner; + +public class LineMenuInputView { + + private static final String LINE_ENROLL_MENU = "1"; + private static final String LINE_DELETE_MENU = "2"; + private static final String LINE_PRINTALL_MENU = "3"; + private static final String INVALID_INPUT = "[ERROR] 선택할 수 없는 기능입니다."; + private static final String BACK_MENU = "B"; + + public static String getLineMenuCommand(Scanner scanner) { + LineMenuOutputView.printLineMenu(); + try { + String lineMenuCommand = scanner.nextLine(); + validateLineMenuCommand(lineMenuCommand); + return lineMenuCommand; + } catch (Exception e) { + System.out.println(e.getMessage()); + return getLineMenuCommand(scanner); + } + } + + private static void validateLineMenuCommand(String lineMenuCommand) { + if (!lineMenuCommand.equals(LINE_ENROLL_MENU) && !lineMenuCommand.equals(LINE_DELETE_MENU) && + !lineMenuCommand.equals(LINE_PRINTALL_MENU) && !lineMenuCommand.equals(BACK_MENU)) { + throw new IllegalArgumentException(INVALID_INPUT); + } + } +} diff --git a/src/main/java/subway/view/line/LineMenuOutputView.java b/src/main/java/subway/view/line/LineMenuOutputView.java new file mode 100644 index 000000000..001f05577 --- /dev/null +++ b/src/main/java/subway/view/line/LineMenuOutputView.java @@ -0,0 +1,17 @@ +package subway.view.line; + +public class LineMenuOutputView { + + private static final String LINE_MENU = "## 노선 관리 화면\n1. 노선 등록\n2. 노선 삭제\n3. 노선 조회\nB. 돌아가기\n"; + private static final String CHOOSE_COMMAND_MESSAGE = "## 원하는 기능을 선택하세요."; + + public static void printLineMenu() { + System.out.println(); + System.out.println(LINE_MENU); + printChooseCommandMessage(); + } + + public static void printChooseCommandMessage() { + System.out.println(CHOOSE_COMMAND_MESSAGE); + } +} From 99918f53b22d1581a7a83815467dcdaddd429694 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 18:13:29 +0900 Subject: [PATCH 06/23] =?UTF-8?q?feat:=20=EA=B5=AC=EA=B0=84=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20inputView=EC=99=80=20outputView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/Application.java | 4 ++- .../subway/view/route/RouteMenuInputView.java | 30 +++++++++++++++++++ .../view/route/RouteMenuOutputView.java | 17 +++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/java/subway/view/route/RouteMenuInputView.java create mode 100644 src/main/java/subway/view/route/RouteMenuOutputView.java diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 3b2ac5ffe..341ceadca 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,6 +1,8 @@ package subway; import subway.view.main.MainMenuInputView; +import subway.view.route.RouteMenuInputView; +import subway.view.route.RouteMenuOutputView; import subway.view.station.StationMenuInputView; import java.util.Scanner; @@ -9,6 +11,6 @@ public class Application { public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); // TODO: 프로그램 구현 - System.out.println(StationMenuInputView.getStationMenuCommand(scanner)); + System.out.println(RouteMenuInputView.getRouteMenuCommand(scanner)); } } diff --git a/src/main/java/subway/view/route/RouteMenuInputView.java b/src/main/java/subway/view/route/RouteMenuInputView.java new file mode 100644 index 000000000..f4301bba6 --- /dev/null +++ b/src/main/java/subway/view/route/RouteMenuInputView.java @@ -0,0 +1,30 @@ +package subway.view.route; + +import java.util.Scanner; + +public class RouteMenuInputView { + + private static final String ROUTE_ENROLL_MENU = "1"; + private static final String ROUTE_DELETE_MENU = "2"; + private static final String INVALID_INPUT = "[ERROR] 선택할 수 없는 기능입니다."; + private static final String BACK_MENU = "B"; + + public static String getRouteMenuCommand(Scanner scanner) { + RouteMenuOutputView.printRouteMenu(); + try { + String routeMenuCommand = scanner.nextLine(); + validateRouteMenuCommand(routeMenuCommand); + return routeMenuCommand; + } catch (Exception e) { + System.out.println(e.getMessage()); + return getRouteMenuCommand(scanner); + } + } + + private static void validateRouteMenuCommand(String routeMenuCommand) { + if (!routeMenuCommand.equals(ROUTE_ENROLL_MENU) && !routeMenuCommand.equals(ROUTE_DELETE_MENU) && + !routeMenuCommand.equals(BACK_MENU)) { + throw new IllegalArgumentException(INVALID_INPUT); + } + } +} diff --git a/src/main/java/subway/view/route/RouteMenuOutputView.java b/src/main/java/subway/view/route/RouteMenuOutputView.java new file mode 100644 index 000000000..277c1cb1d --- /dev/null +++ b/src/main/java/subway/view/route/RouteMenuOutputView.java @@ -0,0 +1,17 @@ +package subway.view.route; + +public class RouteMenuOutputView { + + private static final String ROUTE_MENU = "## 구간 관리 화면\n1. 구간 등록\n2. 구간 삭제\nB. 돌아가기\n"; + private static final String CHOOSE_COMMAND_MESSAGE = "## 원하는 기능을 선택하세요."; + + public static void printRouteMenu() { + System.out.println(); + System.out.println(ROUTE_MENU); + printChooseCommandMessage(); + } + + public static void printChooseCommandMessage() { + System.out.println(CHOOSE_COMMAND_MESSAGE); + } +} From c18f54041c673599076af4ff66f78cc956f439bc Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 19:14:22 +0900 Subject: [PATCH 07/23] =?UTF-8?q?feat:=20=EB=A9=94=EB=89=B4=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EA=B0=84=EB=8B=A8=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/Application.java | 8 ++---- src/main/java/subway/view/InputView.java | 35 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/main/java/subway/view/InputView.java diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 341ceadca..38a3e7556 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,9 +1,6 @@ package subway; -import subway.view.main.MainMenuInputView; -import subway.view.route.RouteMenuInputView; -import subway.view.route.RouteMenuOutputView; -import subway.view.station.StationMenuInputView; +import subway.view.InputView; import java.util.Scanner; @@ -11,6 +8,7 @@ public class Application { public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); // TODO: 프로그램 구현 - System.out.println(RouteMenuInputView.getRouteMenuCommand(scanner)); + InputView.menuRun(scanner); + } } diff --git a/src/main/java/subway/view/InputView.java b/src/main/java/subway/view/InputView.java new file mode 100644 index 000000000..71bfa84d4 --- /dev/null +++ b/src/main/java/subway/view/InputView.java @@ -0,0 +1,35 @@ +package subway.view; + +import subway.view.line.LineMenuInputView; +import subway.view.main.MainMenuInputView; +import subway.view.route.RouteMenuInputView; +import subway.view.station.StationMenuInputView; + +import java.util.Scanner; + +public class InputView { + + public static void menuRun(Scanner scanner) { + String menuChooseResult = MainMenuInputView.getMainMenuCommand(scanner); + while (true) { + if (menuChooseResult.equals("1")) { + if (StationMenuInputView.getStationMenuCommand(scanner).equals("B")) { + MainMenuInputView.getMainMenuCommand(scanner); + } + StationMenuInputView.getStationMenuCommand(scanner); + } + if (menuChooseResult.equals("2")) { + if (LineMenuInputView.getLineMenuCommand(scanner).equals("B")) { + MainMenuInputView.getMainMenuCommand(scanner); + } + LineMenuInputView.getLineMenuCommand(scanner); + } + if (menuChooseResult.equals("3")) { + if (RouteMenuInputView.getRouteMenuCommand(scanner).equals("B")) { + MainMenuInputView.getMainMenuCommand(scanner); + } + RouteMenuInputView.getRouteMenuCommand(scanner); + } + } + } +} From 3841440e52d527b1337bdbf7cccddaee22fdefad Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 22:28:43 +0900 Subject: [PATCH 08/23] =?UTF-8?q?feat:=20station=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EA=B8=80=EC=9E=90=EC=88=98=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subway/domain/{ => station}/Station.java | 2 +- .../subway/domain/station/StationCheck.java | 17 +++++++++++++++++ .../domain/{ => station}/StationRepository.java | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) rename src/main/java/subway/domain/{ => station}/Station.java (86%) create mode 100644 src/main/java/subway/domain/station/StationCheck.java rename src/main/java/subway/domain/{ => station}/StationRepository.java (94%) diff --git a/src/main/java/subway/domain/Station.java b/src/main/java/subway/domain/station/Station.java similarity index 86% rename from src/main/java/subway/domain/Station.java rename to src/main/java/subway/domain/station/Station.java index bdb142590..ef99213b8 100644 --- a/src/main/java/subway/domain/Station.java +++ b/src/main/java/subway/domain/station/Station.java @@ -1,4 +1,4 @@ -package subway.domain; +package subway.domain.station; public class Station { private String name; diff --git a/src/main/java/subway/domain/station/StationCheck.java b/src/main/java/subway/domain/station/StationCheck.java new file mode 100644 index 000000000..6d828c8ae --- /dev/null +++ b/src/main/java/subway/domain/station/StationCheck.java @@ -0,0 +1,17 @@ +package subway.domain.station; + +public class StationCheck { + + private String stationName; + + private static final int MIN_STATION_NAME_LENGTH = 2; + + private static final String STATION_NAME_LENGTH_ERROR_MESSAGE = "[ERROR] 역이름은 2글자 이상 입력해야합니다."; + + public static boolean checkStationNameLength(String stationName) { + if (stationName.length() < MIN_STATION_NAME_LENGTH) { + throw new IllegalArgumentException(STATION_NAME_LENGTH_ERROR_MESSAGE); + } + return true; + } +} diff --git a/src/main/java/subway/domain/StationRepository.java b/src/main/java/subway/domain/station/StationRepository.java similarity index 94% rename from src/main/java/subway/domain/StationRepository.java rename to src/main/java/subway/domain/station/StationRepository.java index b7245c0f3..d9721c09d 100644 --- a/src/main/java/subway/domain/StationRepository.java +++ b/src/main/java/subway/domain/station/StationRepository.java @@ -1,4 +1,4 @@ -package subway.domain; +package subway.domain.station; import java.util.ArrayList; import java.util.Collections; From 4e92c8a3c696198be867f6228294015cc6e7bf1d Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 22:31:44 +0900 Subject: [PATCH 09/23] =?UTF-8?q?feat:=20station=20=EC=9D=B4=EB=A6=84=20'?= =?UTF-8?q?=EC=97=AD'=EC=9C=BC=EB=A1=9C=20=EB=81=9D=EB=82=98=EB=8A=94?= =?UTF-8?q?=EC=A7=80=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/subway/domain/station/StationCheck.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/subway/domain/station/StationCheck.java b/src/main/java/subway/domain/station/StationCheck.java index 6d828c8ae..5375e0495 100644 --- a/src/main/java/subway/domain/station/StationCheck.java +++ b/src/main/java/subway/domain/station/StationCheck.java @@ -6,11 +6,20 @@ public class StationCheck { private static final int MIN_STATION_NAME_LENGTH = 2; - private static final String STATION_NAME_LENGTH_ERROR_MESSAGE = "[ERROR] 역이름은 2글자 이상 입력해야합니다."; + private static final String STATION_LENGTH_ERROR_MESSAGE = "[ERROR] 역이름은 2글자 이상 입력해야합니다."; + public static final String STATION_END_POINT_ERROR_MESSAGE = "[ERROR] 역 이름은 OO역으로 끝나야 합니다."; + public static boolean checkStationNameLength(String stationName) { if (stationName.length() < MIN_STATION_NAME_LENGTH) { - throw new IllegalArgumentException(STATION_NAME_LENGTH_ERROR_MESSAGE); + throw new IllegalArgumentException(STATION_LENGTH_ERROR_MESSAGE); + } + return true; + } + + public static boolean checkStationNameEndPoint(String stationName) { + if (!stationName.endsWith("역")) { + throw new IllegalArgumentException(STATION_END_POINT_ERROR_MESSAGE); } return true; } From 0a1f63e69019aa798e5d116cf74cd63832d3e7fc Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 22:42:24 +0900 Subject: [PATCH 10/23] =?UTF-8?q?feat:=20station=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=ED=9B=84=20=EA=B0=92=20?= =?UTF-8?q?=EB=B0=9B=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/Application.java | 4 +++- src/main/java/subway/domain/station/Station.java | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 38a3e7556..4ba36a7d7 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,5 +1,6 @@ package subway; +import subway.domain.station.Station; import subway.view.InputView; import java.util.Scanner; @@ -8,7 +9,8 @@ public class Application { public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); // TODO: 프로그램 구현 - InputView.menuRun(scanner); + System.out.println("start"); + System.out.println(Station.getStation(scanner.nextLine())); } } diff --git a/src/main/java/subway/domain/station/Station.java b/src/main/java/subway/domain/station/Station.java index ef99213b8..70f36bf6d 100644 --- a/src/main/java/subway/domain/station/Station.java +++ b/src/main/java/subway/domain/station/Station.java @@ -2,6 +2,7 @@ public class Station { private String name; + public static final int MIN_NAME_SIZE = 2; public Station(String name) { this.name = name; @@ -11,5 +12,9 @@ public String getName() { return name; } - // 추가 기능 구현 + public static Station getStation(String stationName) { + if (StationCheck.checkStationNameLength(stationName) && StationCheck.checkStationNameEndPoint(stationName)) { + } + return new Station(stationName); + } } From 2e9bb0041b4ee175b84e698c7c643802c82625b8 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 22:43:41 +0900 Subject: [PATCH 11/23] =?UTF-8?q?feat:=20=EA=B0=9D=EC=B2=B4=EB=8F=99?= =?UTF-8?q?=EC=9D=BC=EC=84=B1=EC=9D=B4=20=EC=95=84=EB=8B=8C=20=EB=85=BC?= =?UTF-8?q?=EB=A6=AC=EC=A0=81=20=EB=8F=99=EC=9D=BC=EC=84=B1=20=EA=B0=9C?= =?UTF-8?q?=EB=85=90=EC=A0=9C=EA=B3=B5=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/subway/domain/station/Station.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/subway/domain/station/Station.java b/src/main/java/subway/domain/station/Station.java index 70f36bf6d..18a0de5d0 100644 --- a/src/main/java/subway/domain/station/Station.java +++ b/src/main/java/subway/domain/station/Station.java @@ -1,9 +1,9 @@ package subway.domain.station; +import java.util.Objects; + public class Station { private String name; - public static final int MIN_NAME_SIZE = 2; - public Station(String name) { this.name = name; } @@ -17,4 +17,21 @@ public static Station getStation(String stationName) { } return new Station(stationName); } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Station station = (Station) o; + return Objects.equals(name, station.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } } From da9ec6847b759d9f273da33370a615eaf8ef20ac Mon Sep 17 00:00:00 2001 From: Gayoung Date: Sun, 13 Dec 2020 23:42:56 +0900 Subject: [PATCH 12/23] =?UTF-8?q?feat:=20station=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EB=B0=8F=20station=20requestdto,=20respon?= =?UTF-8?q?sedto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 1 - src/main/java/subway/Application.java | 12 ++++++-- .../domain/station/StationRepository.java | 15 +++++++--- .../subway/dto/station/StationRequestDto.java | 14 +++++++++ .../dto/station/StationResponseDto.java | 29 +++++++++++++++++++ .../service/station/StationService.java | 15 ++++++++++ 6 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 src/main/java/subway/dto/station/StationRequestDto.java create mode 100644 src/main/java/subway/dto/station/StationResponseDto.java create mode 100644 src/main/java/subway/service/station/StationService.java diff --git a/docs/README.md b/docs/README.md index 7e19bce63..239b1e869 100644 --- a/docs/README.md +++ b/docs/README.md @@ -466,7 +466,6 @@ public class StationRepository { - **역 등록** - 지하철 역 등록하기 `[INFO] 지하철 역이 등록되었습니다.` - - 이름이 입력되지 않은 경우 `[ERROR] null값을 입력하셨습니다.` - 이름은 2글자 이상이여야함 `[ERROR] 역이름은 2글자 이상 입력해야합니다.` - `역`으로 끝나게 이름 작성해야함 `[ERROR] 역이름은 OO역으로 끝나야 합니다.` - 중복되지 않도록 작성해야함 `[ERROR] 이미 등록된 역 이름입니다. 중복되지 않는 역이름을 입력해주세요.` diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 4ba36a7d7..3d96ac57d 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,8 +1,13 @@ package subway; import subway.domain.station.Station; -import subway.view.InputView; +import subway.domain.station.StationRepository; +import subway.dto.station.StationRequestDto; +import subway.dto.station.StationResponseDto; +import subway.service.station.StationService; +import subway.view.main.MainMenuInputView; +import java.util.List; import java.util.Scanner; public class Application { @@ -10,7 +15,10 @@ public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); // TODO: 프로그램 구현 System.out.println("start"); - System.out.println(Station.getStation(scanner.nextLine())); + System.out.println(MainMenuInputView.getMainMenuCommand(scanner)); +// List stationList = StationRepository.save(Station.getStation(scanner.nextLine())); +// System.out.println(StationResponseDto.StationEntityToList(stationList)); +// System.out.println(StationService.save(new StationRequestDto(scanner.nextLine()))); } } diff --git a/src/main/java/subway/domain/station/StationRepository.java b/src/main/java/subway/domain/station/StationRepository.java index d9721c09d..afaf35f64 100644 --- a/src/main/java/subway/domain/station/StationRepository.java +++ b/src/main/java/subway/domain/station/StationRepository.java @@ -1,17 +1,24 @@ package subway.domain.station; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; +import java.util.*; public class StationRepository { private static final List stations = new ArrayList<>(); + public static final String STATION_DUPLICATE_ERROR_MESSAGE = "[ERROR] 이미 등록된 역 이름입니다. 중복되지 않는 역이름을 입력해주세요."; + public static List stations() { return Collections.unmodifiableList(stations); } + public static List save(Station stationName) { + if (stations.contains(stationName)) { + throw new IllegalArgumentException(STATION_DUPLICATE_ERROR_MESSAGE); + } + stations.add(stationName); + return stations; + } + public static void addStation(Station station) { stations.add(station); } diff --git a/src/main/java/subway/dto/station/StationRequestDto.java b/src/main/java/subway/dto/station/StationRequestDto.java new file mode 100644 index 000000000..ca501498b --- /dev/null +++ b/src/main/java/subway/dto/station/StationRequestDto.java @@ -0,0 +1,14 @@ +package subway.dto.station; + +public class StationRequestDto { + + private final String stationName; + + public StationRequestDto(String stationName) { + this.stationName = stationName; + } + + public String getName() { + return stationName; + } +} diff --git a/src/main/java/subway/dto/station/StationResponseDto.java b/src/main/java/subway/dto/station/StationResponseDto.java new file mode 100644 index 000000000..e66393f47 --- /dev/null +++ b/src/main/java/subway/dto/station/StationResponseDto.java @@ -0,0 +1,29 @@ +package subway.dto.station; + +import subway.domain.station.Station; + +import java.util.List; +import java.util.stream.Collectors; + +public class StationResponseDto { + + private final String name; + + public StationResponseDto(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public static StationResponseDto StationEntity(Station entity) { + return new StationResponseDto(entity.getName()); + } + + public static List StationEntityToList(List entities) { + return entities.stream() + .map(StationResponseDto::StationEntity) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/subway/service/station/StationService.java b/src/main/java/subway/service/station/StationService.java new file mode 100644 index 000000000..110b8570c --- /dev/null +++ b/src/main/java/subway/service/station/StationService.java @@ -0,0 +1,15 @@ +package subway.service.station; + +import subway.domain.station.Station; +import subway.domain.station.StationRepository; +import subway.dto.station.StationRequestDto; + +public class StationService { + + public static boolean save(StationRequestDto stationRequestDto) { + Station newStation = Station.getStation(stationRequestDto.getName()); + StationRepository.save(newStation); + System.out.println(StationRepository.save(newStation)); + return true; + } +} From b445f1f8fbfffa5a41adea736de4247bd8918276 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 00:24:22 +0900 Subject: [PATCH 13/23] =?UTF-8?q?feat:=20station=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5(lineList=EB=A7=8C=EB=93=A4=EA=B8=B0=20?= =?UTF-8?q?=EC=9D=B4=EC=A0=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/subway/domain/station/StationRepository.java | 10 ++++++++-- .../java/subway/service/station/StationService.java | 11 +++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/subway/domain/station/StationRepository.java b/src/main/java/subway/domain/station/StationRepository.java index afaf35f64..1c91d7cdd 100644 --- a/src/main/java/subway/domain/station/StationRepository.java +++ b/src/main/java/subway/domain/station/StationRepository.java @@ -6,6 +6,7 @@ public class StationRepository { private static final List stations = new ArrayList<>(); public static final String STATION_DUPLICATE_ERROR_MESSAGE = "[ERROR] 이미 등록된 역 이름입니다. 중복되지 않는 역이름을 입력해주세요."; + public static final String STATION_CANNOT_FIND_ERROR_MESSAGE = "[ERROR] 존재하지 않는 역입니다."; public static List stations() { return Collections.unmodifiableList(stations); @@ -23,7 +24,12 @@ 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 Station findStationName(String stationName) { + return stations.stream().filter(station -> station.getName().equals(stationName)) + .findAny().orElseThrow(() -> new IllegalArgumentException(STATION_CANNOT_FIND_ERROR_MESSAGE)); + } + + public static boolean deleteStation(Station stationName) { + return stations.remove(stationName); } } diff --git a/src/main/java/subway/service/station/StationService.java b/src/main/java/subway/service/station/StationService.java index 110b8570c..30619aade 100644 --- a/src/main/java/subway/service/station/StationService.java +++ b/src/main/java/subway/service/station/StationService.java @@ -1,15 +1,26 @@ package subway.service.station; +import subway.domain.Line; import subway.domain.station.Station; import subway.domain.station.StationRepository; import subway.dto.station.StationRequestDto; public class StationService { + public static final String STATION_DELETE_CONDITION_ERROR_MESSAGE = "[ERROR] 노선에 등록되어있는 역은 삭제가 불가능합니다."; + public static boolean save(StationRequestDto stationRequestDto) { Station newStation = Station.getStation(stationRequestDto.getName()); StationRepository.save(newStation); System.out.println(StationRepository.save(newStation)); return true; } + + public static boolean delete(String stationName) { + Station station = StationRepository.findStationName(stationName); + if (LineList.contains(stationName)) { // 노선에 역이 포함되어있다면 + throw new IllegalArgumentException(STATION_DELETE_CONDITION_ERROR_MESSAGE); + } + StationRepository.deleteStation(station); + } } From a0f9bc1fa5878aad122758202f6c65bd58167126 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 12:51:09 +0900 Subject: [PATCH 14/23] =?UTF-8?q?feat:=20line=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EA=B8=80=EC=9E=90=EC=88=98=20=EC=98=88=EC=99=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/subway/domain/{ => list}/Line.java | 2 +- src/main/java/subway/domain/list/LineCheck.java | 17 +++++++++++++++++ .../domain/{ => list}/LineRepository.java | 2 +- .../subway/service/station/StationService.java | 1 - 4 files changed, 19 insertions(+), 3 deletions(-) rename src/main/java/subway/domain/{ => list}/Line.java (87%) create mode 100644 src/main/java/subway/domain/list/LineCheck.java rename src/main/java/subway/domain/{ => list}/LineRepository.java (94%) diff --git a/src/main/java/subway/domain/Line.java b/src/main/java/subway/domain/list/Line.java similarity index 87% rename from src/main/java/subway/domain/Line.java rename to src/main/java/subway/domain/list/Line.java index f4d738d5a..8b54122bf 100644 --- a/src/main/java/subway/domain/Line.java +++ b/src/main/java/subway/domain/list/Line.java @@ -1,4 +1,4 @@ -package subway.domain; +package subway.domain.list; public class Line { private String name; diff --git a/src/main/java/subway/domain/list/LineCheck.java b/src/main/java/subway/domain/list/LineCheck.java new file mode 100644 index 000000000..d0daa3412 --- /dev/null +++ b/src/main/java/subway/domain/list/LineCheck.java @@ -0,0 +1,17 @@ +package subway.domain.list; + +public class LineCheck { + + private String lineName; + + private static final int MIN_LINE_NAME_LENGTH = 2; + + private static final String LINE_LENGTH_ERROR_MESSAGE = "[ERROR] 노선 이름은 2글자 이상 입력해야합니다."; + + public static boolean checkLineNameLength(String lineName) { + if (lineName.length() < MIN_LINE_NAME_LENGTH) { + throw new IllegalArgumentException(LINE_LENGTH_ERROR_MESSAGE); + } + return true; + } +} diff --git a/src/main/java/subway/domain/LineRepository.java b/src/main/java/subway/domain/list/LineRepository.java similarity index 94% rename from src/main/java/subway/domain/LineRepository.java rename to src/main/java/subway/domain/list/LineRepository.java index 49132ddb6..e4c2ede84 100644 --- a/src/main/java/subway/domain/LineRepository.java +++ b/src/main/java/subway/domain/list/LineRepository.java @@ -1,4 +1,4 @@ -package subway.domain; +package subway.domain.list; import java.util.ArrayList; import java.util.Collections; diff --git a/src/main/java/subway/service/station/StationService.java b/src/main/java/subway/service/station/StationService.java index 30619aade..41fe07284 100644 --- a/src/main/java/subway/service/station/StationService.java +++ b/src/main/java/subway/service/station/StationService.java @@ -1,6 +1,5 @@ package subway.service.station; -import subway.domain.Line; import subway.domain.station.Station; import subway.domain.station.StationRepository; import subway.dto.station.StationRequestDto; From 9bd905fe75844939842c34004cc6c6bbdfc448f3 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 12:53:34 +0900 Subject: [PATCH 15/23] =?UTF-8?q?feat:=20line=20=EC=9D=B4=EB=A6=84=20'?= =?UTF-8?q?=EC=84=A0'=EB=98=90=EB=8A=94=20'=ED=98=B8=EC=84=A0'=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=81=9D=EB=82=98=EB=8A=94=EC=A7=80=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/domain/list/LineCheck.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/subway/domain/list/LineCheck.java b/src/main/java/subway/domain/list/LineCheck.java index d0daa3412..4a86ee4e0 100644 --- a/src/main/java/subway/domain/list/LineCheck.java +++ b/src/main/java/subway/domain/list/LineCheck.java @@ -2,11 +2,10 @@ public class LineCheck { - private String lineName; - private static final int MIN_LINE_NAME_LENGTH = 2; private static final String LINE_LENGTH_ERROR_MESSAGE = "[ERROR] 노선 이름은 2글자 이상 입력해야합니다."; + public static final String LINE_END_POINT_ERROR_MESSAGE = "[ERROR] 노선이름은 OO선 또는 O호선으로 끝나야 합니다."; public static boolean checkLineNameLength(String lineName) { if (lineName.length() < MIN_LINE_NAME_LENGTH) { @@ -14,4 +13,11 @@ public static boolean checkLineNameLength(String lineName) { } return true; } + + public static boolean checkLineNameEndPoint(String lineName) { + if (!lineName.endsWith("선") || !lineName.endsWith("호선")) { + throw new IllegalArgumentException(LINE_END_POINT_ERROR_MESSAGE); + } + return true; + } } From a52be4fdf9732d8dfff8b56c6293d71cd883f066 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 12:57:23 +0900 Subject: [PATCH 16/23] =?UTF-8?q?feat:=20line=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=ED=9B=84=20=EA=B0=92=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0+=EB=85=BC=EB=A6=AC?= =?UTF-8?q?=EC=A0=81=EB=8F=99=EC=9D=BC=EC=84=B1=20=EC=A0=9C=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/domain/list/Line.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/subway/domain/list/Line.java b/src/main/java/subway/domain/list/Line.java index 8b54122bf..3305278b5 100644 --- a/src/main/java/subway/domain/list/Line.java +++ b/src/main/java/subway/domain/list/Line.java @@ -1,5 +1,10 @@ package subway.domain.list; +import subway.domain.station.Station; +import subway.domain.station.StationCheck; + +import java.util.Objects; + public class Line { private String name; @@ -11,5 +16,26 @@ public String getName() { return name; } - // 추가 기능 구현 + public static Line getLine(String lineName) { + if (LineCheck.checkLineNameLength(lineName) && LineCheck.checkLineNameEndPoint(lineName)) { + } + return new Line(lineName); + } + + @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); + } } From eb92e44ef92e464b804c575cd15afcff8fe88345 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 13:33:38 +0900 Subject: [PATCH 17/23] =?UTF-8?q?feat:=20line=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?=ED=9B=84=20=EC=83=81=ED=96=89/=ED=95=98=ED=96=89=20=EC=A2=85?= =?UTF-8?q?=EC=A0=90=EC=97=AD=20=EC=9E=85=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/Application.java | 9 +++++++-- src/main/java/subway/domain/list/Line.java | 12 ++++++++---- .../subway/service/station/StationService.java | 14 +++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 3d96ac57d..6dd19f282 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,5 +1,6 @@ package subway; +import subway.domain.list.Line; import subway.domain.station.Station; import subway.domain.station.StationRepository; import subway.dto.station.StationRequestDto; @@ -15,8 +16,12 @@ public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); // TODO: 프로그램 구현 System.out.println("start"); - - System.out.println(MainMenuInputView.getMainMenuCommand(scanner)); + System.out.println("startStation"); + Station startStation = Station.getStation(scanner.nextLine()); + System.out.println("endStation"); + Station endStation = Station.getStation(scanner.nextLine()); + System.out.println(Line.getLine("2호", startStation, endStation)); +// System.out.println(MainMenuInputView.getMainMenuCommand(scanner)); // List stationList = StationRepository.save(Station.getStation(scanner.nextLine())); // System.out.println(StationResponseDto.StationEntityToList(stationList)); // System.out.println(StationService.save(new StationRequestDto(scanner.nextLine()))); diff --git a/src/main/java/subway/domain/list/Line.java b/src/main/java/subway/domain/list/Line.java index 3305278b5..1011c13e5 100644 --- a/src/main/java/subway/domain/list/Line.java +++ b/src/main/java/subway/domain/list/Line.java @@ -3,23 +3,27 @@ import subway.domain.station.Station; import subway.domain.station.StationCheck; +import java.util.Arrays; +import java.util.List; import java.util.Objects; public class Line { - private String name; + private final String name; + private final List stationList; - public Line(String name) { + public Line(String name, List stationList) { this.name = name; + this.stationList = stationList; } public String getName() { return name; } - public static Line getLine(String lineName) { + public static Line getLine(String lineName, Station startStation, Station endStation) { if (LineCheck.checkLineNameLength(lineName) && LineCheck.checkLineNameEndPoint(lineName)) { } - return new Line(lineName); + return new Line(lineName, Arrays.asList(startStation, endStation)); } @Override diff --git a/src/main/java/subway/service/station/StationService.java b/src/main/java/subway/service/station/StationService.java index 41fe07284..20a8ac9d5 100644 --- a/src/main/java/subway/service/station/StationService.java +++ b/src/main/java/subway/service/station/StationService.java @@ -15,11 +15,11 @@ public static boolean save(StationRequestDto stationRequestDto) { return true; } - public static boolean delete(String stationName) { - Station station = StationRepository.findStationName(stationName); - if (LineList.contains(stationName)) { // 노선에 역이 포함되어있다면 - throw new IllegalArgumentException(STATION_DELETE_CONDITION_ERROR_MESSAGE); - } - StationRepository.deleteStation(station); - } +// public static boolean delete(String stationName) { +// Station station = StationRepository.findStationName(stationName); +// if (LineList.contains(stationName)) { // 노선에 역이 포함되어있다면 +// throw new IllegalArgumentException(STATION_DELETE_CONDITION_ERROR_MESSAGE); +// } +// StationRepository.deleteStation(station); +// } } From bf8d0c0249d71bc185ebac20e4e580dcd640a0c8 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 13:46:25 +0900 Subject: [PATCH 18/23] =?UTF-8?q?feat:=20line=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/subway/domain/list/LineRepository.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/subway/domain/list/LineRepository.java b/src/main/java/subway/domain/list/LineRepository.java index e4c2ede84..a3bf6f02a 100644 --- a/src/main/java/subway/domain/list/LineRepository.java +++ b/src/main/java/subway/domain/list/LineRepository.java @@ -1,17 +1,30 @@ package subway.domain.list; +import subway.domain.station.Station; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; public class LineRepository { + private static final List lines = new ArrayList<>(); + public static final String LINE_DUPLICATE_ERROR_MESSAGE = "[ERROR] 이미 등록된 노선 이름입니다. 중복되지 않는 역이름을 입력해주세요."; + public static List lines() { return Collections.unmodifiableList(lines); } + public static List save(Line lineName) { + if (lines.contains(lineName)) { + throw new IllegalArgumentException(LINE_DUPLICATE_ERROR_MESSAGE); + } + lines.add(lineName); + return lines; + } + public static void addLine(Line line) { lines.add(line); } From f81c45df20470caf40bc465a14b46cb35327a3c6 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 14:01:26 +0900 Subject: [PATCH 19/23] =?UTF-8?q?feat:=20line=EC=9D=B4=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=8A=94=EC=A7=80=20=EB=85=B8=EC=84=A0?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=EC=9C=BC=EB=A1=9C=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/domain/list/LineRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/subway/domain/list/LineRepository.java b/src/main/java/subway/domain/list/LineRepository.java index a3bf6f02a..8ec6b7b8c 100644 --- a/src/main/java/subway/domain/list/LineRepository.java +++ b/src/main/java/subway/domain/list/LineRepository.java @@ -12,6 +12,7 @@ public class LineRepository { private static final List lines = new ArrayList<>(); public static final String LINE_DUPLICATE_ERROR_MESSAGE = "[ERROR] 이미 등록된 노선 이름입니다. 중복되지 않는 역이름을 입력해주세요."; + public static final String LINE_CANNOT_FIND_ERROR_MESSAGE = "[ERROR] 존재하지 않는 노선입니다."; public static List lines() { return Collections.unmodifiableList(lines); @@ -25,6 +26,12 @@ public static List save(Line lineName) { return lines; } + // 구간 입력할 때 존재하는 노선인지 확인 + public static Line findLineName(String lineName) { + return lines.stream().filter(line -> line.getName().equals(lineName)) + .findAny().orElseThrow(() -> new IllegalArgumentException(LINE_CANNOT_FIND_ERROR_MESSAGE)); + } + public static void addLine(Line line) { lines.add(line); } From 8e9adf4b88e71a3d8d8042383804c4e199573e3e Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 22:30:44 +0900 Subject: [PATCH 20/23] =?UTF-8?q?feat:=20station=EC=82=AD=EC=A0=9C(line?= =?UTF-8?q?=EC=97=90=20=ED=8F=AC=ED=95=A8=EB=90=98=EC=96=B4=EC=9E=88?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/domain/list/Line.java | 4 ++++ src/main/java/subway/domain/list/LineRepository.java | 5 +++++ .../java/subway/domain/station/StationRepository.java | 11 +++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/subway/domain/list/Line.java b/src/main/java/subway/domain/list/Line.java index 1011c13e5..06eb11c68 100644 --- a/src/main/java/subway/domain/list/Line.java +++ b/src/main/java/subway/domain/list/Line.java @@ -42,4 +42,8 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(name); } + + public boolean contains(Station station) { + return stationList.contains(station); + } } diff --git a/src/main/java/subway/domain/list/LineRepository.java b/src/main/java/subway/domain/list/LineRepository.java index 8ec6b7b8c..bc6e8c9bb 100644 --- a/src/main/java/subway/domain/list/LineRepository.java +++ b/src/main/java/subway/domain/list/LineRepository.java @@ -32,6 +32,11 @@ public static Line findLineName(String lineName) { .findAny().orElseThrow(() -> new IllegalArgumentException(LINE_CANNOT_FIND_ERROR_MESSAGE)); } + // station이 line에 포함되어있는지 확인 + public static boolean contains(Station station) { + return lines.stream().anyMatch(line -> line.contains(station)); + } + public static void addLine(Line line) { lines.add(line); } diff --git a/src/main/java/subway/domain/station/StationRepository.java b/src/main/java/subway/domain/station/StationRepository.java index 1c91d7cdd..1471174c6 100644 --- a/src/main/java/subway/domain/station/StationRepository.java +++ b/src/main/java/subway/domain/station/StationRepository.java @@ -1,5 +1,7 @@ package subway.domain.station; +import subway.domain.list.LineRepository; + import java.util.*; public class StationRepository { @@ -7,6 +9,7 @@ public class StationRepository { public static final String STATION_DUPLICATE_ERROR_MESSAGE = "[ERROR] 이미 등록된 역 이름입니다. 중복되지 않는 역이름을 입력해주세요."; public static final String STATION_CANNOT_FIND_ERROR_MESSAGE = "[ERROR] 존재하지 않는 역입니다."; + public static final String LINE_ALREADY_CONTAINS_STATION_ERROR_MESSAGE = "[ERROR] 노선에 등록되어있는 역은 삭제가 불가능합니다."; public static List stations() { return Collections.unmodifiableList(stations); @@ -29,7 +32,11 @@ public static Station findStationName(String stationName) { .findAny().orElseThrow(() -> new IllegalArgumentException(STATION_CANNOT_FIND_ERROR_MESSAGE)); } - public static boolean deleteStation(Station stationName) { - return stations.remove(stationName); + public static boolean deleteStation(String stationName) { + Station targetStation = findStationName(stationName); + if (LineRepository.contains(targetStation)) { + throw new IllegalArgumentException(LINE_ALREADY_CONTAINS_STATION_ERROR_MESSAGE); + } + return stations.removeIf(station -> Objects.equals(station.getName(), stationName)); } } From 59a5ebb743b1827d8e9953d71fdd141051acc4b2 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Mon, 14 Dec 2020 22:37:08 +0900 Subject: [PATCH 21/23] =?UTF-8?q?style:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/Application.java | 8 +------- src/main/java/subway/domain/{list => line}/Line.java | 3 +-- src/main/java/subway/domain/{list => line}/LineCheck.java | 2 +- .../java/subway/domain/{list => line}/LineRepository.java | 7 ++----- .../java/subway/domain/station/StationRepository.java | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) rename src/main/java/subway/domain/{list => line}/Line.java (94%) rename src/main/java/subway/domain/{list => line}/LineCheck.java (96%) rename src/main/java/subway/domain/{list => line}/LineRepository.java (93%) diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java index 6dd19f282..7cba546b7 100644 --- a/src/main/java/subway/Application.java +++ b/src/main/java/subway/Application.java @@ -1,14 +1,8 @@ package subway; -import subway.domain.list.Line; +import subway.domain.line.Line; import subway.domain.station.Station; -import subway.domain.station.StationRepository; -import subway.dto.station.StationRequestDto; -import subway.dto.station.StationResponseDto; -import subway.service.station.StationService; -import subway.view.main.MainMenuInputView; -import java.util.List; import java.util.Scanner; public class Application { diff --git a/src/main/java/subway/domain/list/Line.java b/src/main/java/subway/domain/line/Line.java similarity index 94% rename from src/main/java/subway/domain/list/Line.java rename to src/main/java/subway/domain/line/Line.java index 06eb11c68..03ffdf09f 100644 --- a/src/main/java/subway/domain/list/Line.java +++ b/src/main/java/subway/domain/line/Line.java @@ -1,7 +1,6 @@ -package subway.domain.list; +package subway.domain.line; import subway.domain.station.Station; -import subway.domain.station.StationCheck; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/subway/domain/list/LineCheck.java b/src/main/java/subway/domain/line/LineCheck.java similarity index 96% rename from src/main/java/subway/domain/list/LineCheck.java rename to src/main/java/subway/domain/line/LineCheck.java index 4a86ee4e0..baeec9b5f 100644 --- a/src/main/java/subway/domain/list/LineCheck.java +++ b/src/main/java/subway/domain/line/LineCheck.java @@ -1,4 +1,4 @@ -package subway.domain.list; +package subway.domain.line; public class LineCheck { diff --git a/src/main/java/subway/domain/list/LineRepository.java b/src/main/java/subway/domain/line/LineRepository.java similarity index 93% rename from src/main/java/subway/domain/list/LineRepository.java rename to src/main/java/subway/domain/line/LineRepository.java index bc6e8c9bb..4259f40aa 100644 --- a/src/main/java/subway/domain/list/LineRepository.java +++ b/src/main/java/subway/domain/line/LineRepository.java @@ -1,4 +1,4 @@ -package subway.domain.list; +package subway.domain.line; import subway.domain.station.Station; @@ -37,10 +37,7 @@ public static boolean contains(Station station) { return lines.stream().anyMatch(line -> line.contains(station)); } - public static void addLine(Line line) { - lines.add(line); - } - + // 노선 삭제 public static boolean deleteLineByName(String name) { return lines.removeIf(line -> Objects.equals(line.getName(), name)); } diff --git a/src/main/java/subway/domain/station/StationRepository.java b/src/main/java/subway/domain/station/StationRepository.java index 1471174c6..54f028921 100644 --- a/src/main/java/subway/domain/station/StationRepository.java +++ b/src/main/java/subway/domain/station/StationRepository.java @@ -1,6 +1,6 @@ package subway.domain.station; -import subway.domain.list.LineRepository; +import subway.domain.line.LineRepository; import java.util.*; From ce9c2df2fa87cf11aa377fdbc521827b71b42f2c Mon Sep 17 00:00:00 2001 From: Gayoung Date: Tue, 15 Dec 2020 00:02:43 +0900 Subject: [PATCH 22/23] =?UTF-8?q?feat:=20=EA=B5=AC=EA=B0=84=EC=97=90=20sta?= =?UTF-8?q?tion=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/domain/line/Line.java | 4 ++++ src/main/java/subway/domain/line/LineRepository.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/subway/domain/line/Line.java b/src/main/java/subway/domain/line/Line.java index 03ffdf09f..be92e331e 100644 --- a/src/main/java/subway/domain/line/Line.java +++ b/src/main/java/subway/domain/line/Line.java @@ -45,4 +45,8 @@ public int hashCode() { public boolean contains(Station station) { return stationList.contains(station); } + + public void insertSection(int index, Station station) { + stationList.add(index, station); + } } diff --git a/src/main/java/subway/domain/line/LineRepository.java b/src/main/java/subway/domain/line/LineRepository.java index 4259f40aa..b53a21740 100644 --- a/src/main/java/subway/domain/line/LineRepository.java +++ b/src/main/java/subway/domain/line/LineRepository.java @@ -41,4 +41,10 @@ public static boolean contains(Station station) { public static boolean deleteLineByName(String name) { return lines.removeIf(line -> Objects.equals(line.getName(), name)); } + + // 구간에 station추가 + public static void insertSection(String lineName, int index, Station station) { + Line line = findLineName(lineName); + line.insertSection(index, station); + } } From 307bea7e0dad326a604c159e9b42902886b61b48 Mon Sep 17 00:00:00 2001 From: Gayoung Date: Tue, 15 Dec 2020 22:37:41 +0900 Subject: [PATCH 23/23] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B3=B8=EC=A0=9C?= =?UTF-8?q?=EA=B3=B5=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/subway/DummyData.java | 31 +++++++++++++++++++ .../subway/domain/line/LineRepository.java | 8 +++++ .../domain/station/StationRepository.java | 5 +++ 3 files changed, 44 insertions(+) create mode 100644 src/main/java/subway/DummyData.java diff --git a/src/main/java/subway/DummyData.java b/src/main/java/subway/DummyData.java new file mode 100644 index 000000000..53d8bc565 --- /dev/null +++ b/src/main/java/subway/DummyData.java @@ -0,0 +1,31 @@ +package subway; + +import subway.domain.line.Line; +import subway.domain.line.LineRepository; +import subway.domain.station.Station; +import subway.domain.station.StationRepository; + +import java.util.Arrays; + +public class DummyData { + + public static void saveDummyData() { + Station station1 = Station.getStation("교대역"); + Station station2 = Station.getStation("강남역"); + Station station3 = Station.getStation("역삼역"); + Station station4 = Station.getStation("남부터미널역"); + Station station5 = Station.getStation("양재역"); + Station station6 = Station.getStation("양재시민의숲역"); + Station station7 = Station.getStation("매봉역"); + + StationRepository.saveDummyData( + Arrays.asList(station1, station2, station3, station4, station5, station6, station7) + ); + + Line line1 = Line.getLine("2호선", station1, station2); + Line line2 = Line.getLine("3호선", station1, station4); + Line line3 = Line.getLine("신분당선", station2, station5); + + LineRepository.saveDummyData(Arrays.asList(line1, line2, line3)); + } +} diff --git a/src/main/java/subway/domain/line/LineRepository.java b/src/main/java/subway/domain/line/LineRepository.java index b53a21740..00068abf3 100644 --- a/src/main/java/subway/domain/line/LineRepository.java +++ b/src/main/java/subway/domain/line/LineRepository.java @@ -1,6 +1,7 @@ package subway.domain.line; import subway.domain.station.Station; +import subway.domain.station.StationRepository; import java.util.ArrayList; import java.util.Collections; @@ -47,4 +48,11 @@ public static void insertSection(String lineName, int index, Station station) { Line line = findLineName(lineName); line.insertSection(index, station); } + + public static void saveDummyData(List lines) { + lines.forEach(LineRepository::save); + } + + // 구간에 station제거 +// public static } diff --git a/src/main/java/subway/domain/station/StationRepository.java b/src/main/java/subway/domain/station/StationRepository.java index 54f028921..bb212bd92 100644 --- a/src/main/java/subway/domain/station/StationRepository.java +++ b/src/main/java/subway/domain/station/StationRepository.java @@ -32,6 +32,7 @@ public static Station findStationName(String stationName) { .findAny().orElseThrow(() -> new IllegalArgumentException(STATION_CANNOT_FIND_ERROR_MESSAGE)); } + // Line에 station포함되어있으면 station 삭제 못함 public static boolean deleteStation(String stationName) { Station targetStation = findStationName(stationName); if (LineRepository.contains(targetStation)) { @@ -39,4 +40,8 @@ public static boolean deleteStation(String stationName) { } return stations.removeIf(station -> Objects.equals(station.getName(), stationName)); } + + public static void saveDummyData(List stations) { + stations.forEach(StationRepository::save); + } }