diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 000000000..979905fc3
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,83 @@
+# 서비스 파악 및 구현 계획
+> **지하철 역과 노선을 관리하는 지하철 노선도 기능을 구현한 코드**
+
+### 사전등록정보
+- 교대역, 강남역, 역삼역, 남부터미널역, 양재역, 양재시민의 숲역, 매봉역
+ - 하행 - 상행
+- 2호선: 교대역 - 강남역 - 역삼역
+- 3호선: 교대역 - 남부터미널역 - 양재역 - 매봉역
+- 신분당선: 강남역 - 양재역 - 양재시민의숲역
+
+# Controller
+- 사용자 입력과 Service 코드 매칭
+- 유효한 입력인지 확인 ```(Exception 1)```
+
+# Service
+### Managerable
+- 공통 기능 추출 후 추상화
+ - 역 관련 기능/지하철 노선 등록/노선 구간 추가 기능 service 코드가 확장
+- 등록/삭제/조회/(메인화면으로)돌아가기
+```aidl
+public abstract class Managerable{}
+```
+> interface 로 초기 기획하다가 추상 클래스로 변경함.
+> **되돌아가기**을 공통적으로 갖고 있으며 기능 수행 후 **출력하는 내용**이 거의 비슷하니 확장하는 방향으로 변경.
+> 맞는 선택인지 구현하면서 계속 고민해볼 것
+
+### StationManagerImpl
+> 역 관련 기능
+- 지하철 역 등록
+ - 등록 이후 노선에 등록하지 않기
+ - 노선에 등록되어 있으면 중복 등록 불가 ```(SubwayConstraintHandler.2)```
+- 지하철 역 삭제
+ - 노선에 등록된 역은 삭제할 수 없다. ```(SubwayConstraintHandler.2)```
+- 지하철 역의 목록 조회
+ - 지하철 역 가나다순 나열하기
+ - 역 이름 앞에 **'[INFO]'** 붙이기 ```(view )```
+ - 한줄씩 출력
+
+- View 코드에서 출력 포맷 활용하여 구현하고 호출할 때 매개변수로 구문이 다르게 나가도록
+ - 출력 포맷 적극 활용할 것
+
+### LineManagerImpl
+> 지하철 노선 등록
+- 노선 등록
+ 1. 노선 이름 입력
+ 2. 상행 종점 이름 입력
+ 3. 하행 종점 이름 입력
+ 4. **'[INFO] 지하철 노선이 등록되었습니다.'** ```(view)```
+- 지하철 노선 삭제
+- 지하철 노선 목록 조회
+ - **'[INFO] n 호선/신분당선'** 나열 ```(view)```
+
+### SectionManagerImpl
+> 노선에 구간 추가
+- 구간 등록
+ 1. 등록한 노선 입력 ```(SubwayConstraintHandler.2 : true-continue, false - retry)```
+ 2. 등록할 역 이름 입력
+ 3. 노선에서 차지할 순서 입력
+ 4. **'[INFO] 지하철 구간이 등록되었습니다.'** ```(view)```
+
+### MapServcie
+> 지하철 노선에 등록된 역 조회
+- 노선의 상행 종점부터 하행 종점까지 연결된 순으로 역 목록 조회
+
+
+
+# config
+> 1. 에러나 제약 사항 체크
+> 2. 상수값 모음
+
+위반 시 **[ERROR]** 를 반드시 앞에 붙인다.
+
+### SubwayException
+Controller 에서 주로 사용되는 예외
+1. 제공되는 서비스 외 문자 입력 및 선택 시 발생
+
+### SubwayConstraintHandler
+Service 에서 주로 사용되는 예외
+1. 지하철 역/노선 이름은 2글자 이상인지 확인
+ - 아니면 다시 입력 받도록
+2. 노선에 등록되어있는지 확인(수정 및 업데이트 시)
+ - 있으면 true 없으면 false
+3. 노선에 등록되어있는지 확인(조회 시)
diff --git a/docs/modules.md b/docs/modules.md
new file mode 100644
index 000000000..0af834771
--- /dev/null
+++ b/docs/modules.md
@@ -0,0 +1,133 @@
+# TODO
+
+## controller
+### Maincontroller
+각각의 controller 를 실행하는 객체
+사용자의 입력에 맞게 올바른 controller 배치
+- [ ] 1을 입력하면 StationController와 연결된다.
+- [ ] 2을 입력하면 LineController와 연결된다.
+- [ ] 3을 입력하면 SectionController와 연결된다.
+- [ ] 4를 입력하면 지하철 노선을 출력하는 컨트롤러와 연결된다.
+- [ ] Q 를 입력하기 전까지 사용자의 입력을 받아 서비스를 제공한다.
+
+### LineController
+지하철 노선과 관련한 기능을 관장하는 객체
+- [ ] 1을 입력하면 노선을 등록한다.
+- [ ] 2를 입력하면 노선을 삭제한다
+- [ ] 3을 입력하면 노선 목록을 조회한다.
+- [ ] B 를 입력하면 메인 화면으로 되돌아간다.
+
+#### - 주의사항
+- [ ] 이미 등록된 이름의 노선은 추가할 수 없다.
+- [ ] 노선 이름은 2글자 이상이어야 한다.
+- [ ] 등록 시 상행 종점, 하행 종점을 입력받는다.
+- [ ] 노선에 등록된 역 이름을 나열할 수 있다.
+- [ ] 하나의 역은 여러개의 노선에 추가될 수 있다.
+
+### SectionController
+역과 역 사이 구간을 관리하는 객체
+- [ ] 1을 입력하면 구간을 등록한다.
+- [ ] 2를 입력하면 구간을 삭제한다.
+- [ ] B 를 입력하면 메인 화면으로 되돌아간다.
+
+#### - 주의사항
+- [ ] 노선에서 갈래길이 생길 수 없다.
+- [ ] 역과 역 사이에 새로운 역이 추가될 수 있다.
+- [ ] 노선에 등록된 역을 삭제할 수 있다.
+- [ ] 종점을 제거하면 다음 역이 종점이 된다.
+- [ ] 노선에 포함된 역이 2개 이하일 때 제거할 수 없다.
+
+### StationController
+지하철 역과 관련한 기능을 관장하는 객체
+- [ ] 1을 입력하면 역을 등록한다.
+- [ ] 2를 입력하면 역을 삭제한다
+- [ ] 3을 입력하면 역 목록을 조회한다.
+- [ ] B 를 입력하면 메인 화면으로 되돌아간다.
+
+#### - 주의사항
+- [ ] 이미 등록된 이름의 역은 추가할 수 없다.
+- [ ] 역 이름은 2글자 이상이어야 한다.
+- [ ] 노선에 등록된 역은 삭제할 수 없다.
+
+### 지하철 노선에 등록된 역 조회 기능
+- [ ] 상행 종점부터 하행 종점까지 순서대로 나열한다.
+
+
+
+
+
+## Service
+### Managerable
+각각의 Service 들중 공통적으로 필요한 메서드를 나열 하는 추상클래스
+- [ ] 등록
+- [ ] 삭제
+- [ ] 조회
+- [ ] 되돌아가기 - 메인화면
+
+### LineManager
+노선 관련한 서비스를 모은 집약체
+- [ ] 노선 등록
+ - [ ] 이름으로 노선 객체를 불러올 수 있다.
+ - [ ] 노선 객체에 상행 종점과 하행 종점을 저장한다.
+ - [ ] 저장하는 배열의 가장 처음을 상행 종점, 가장 마지막을 하행 종점으로 지정한다.
+ - [ ] 사용자가 입력한 이름이 노선 목록에 존재하지 않을 경우에만 노선을 생성한다.
+ - [ ] 사용자가 입력한 이름이 2글자 이상 되지 않는다면 노선을 생성하지 않는다. - 메인화면으로
+ - [ ] 노선에 등록된 역은 속한 노선 이름을 저장할 수 있다.
+- [ ] 노선 삭제
+ - [ ] 노선을 삭제한다고 역이 삭제되지는 않는다.
+- [ ] 노선 목록 조회
+
+### SectionManager
+구간 관련한 서비스를 모은 집약체
+- [ ] 구간 등록
+ - [ ] 역을 저장한 1차원 배열에서 올바른 위치에 역을 삽입할 수 있다.
+ - [ ] 존재하지 않는 역을 생성하여 구간을 만들 수 없다.
+- [ ] 구간 삭제
+ - [ ] 역을 저장한 1차원 배열에서 해당하는 역을 삭제할 수 있다.
+ - [ ] 노선에 포함된 역이 2개 이상일 때 삭제할 수 없다. - 메인 화면으로
+ - [ ] 종점을 제거하면 다음 역이 종점이 된다.
+- [ ] 되돌아가기 - 메인화면
+
+### StationManager
+역과 관련한 서비스를 모은 집약체
+- [ ] 역 등록
+ - [ ] 2글자 이상일 때 등록이 가능하다.
+ - [ ] 이미 존재하는 이름으로 등록은 불가능하다. - 메인화면
+ - [ ] 구간 등록을 하지 않은 역은 어떤 노선과도 연결되지 않는다.
+- [ ] 역 삭제
+ - [ ] 노선에 등록되어 있는 역은 삭제할 수 없다.
+- [ ] 역 조회
+- [ ] 되돌아가기 - 메인화면
+
+
+
+
+
+## View
+- [ ] 매개변수를 활용하여 코드의 재사용성을 극대화한다.
+### Askview
+- [ ] \## 00할 00을 입력하세요.
+- [ ] \## 원하는 기능을 선택하세요.
+
+### Responseview
+- [ ] \[INFO] 지하철 00이 00되었습니다.
+- [ ] \## 00 목록
+- [ ] \[INFO] 00
+- [ ] \## 00 화면
+- [ ] 노선/역/구간
+```aidl
+// 노선/역/구간
+1. 00 등록
+2. 00 삭제
+3. 00 조회
+B. 돌아가기
+```
+
+```aidl
+// main 화면
+1. 역 관리
+2. 노선 관리
+3. 구간 관리
+4. 지하철 노선도 출력
+Q. 종료
+```
\ No newline at end of file
diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java
index 0bcf786cc..4e44bba62 100644
--- a/src/main/java/subway/Application.java
+++ b/src/main/java/subway/Application.java
@@ -1,10 +1,9 @@
package subway;
-import java.util.Scanner;
-
+import subway.controller.MainController;
public class Application {
- public static void main(String[] args) {
- final Scanner scanner = new Scanner(System.in);
- // TODO: 프로그램 구현
+ public static void main(String[] args) throws Exception {
+ MainController main = new MainController();
+ main.headController();
}
}
diff --git a/src/main/java/subway/config/constants/initValues/Lines.java b/src/main/java/subway/config/constants/initValues/Lines.java
new file mode 100644
index 000000000..4c83cb165
--- /dev/null
+++ b/src/main/java/subway/config/constants/initValues/Lines.java
@@ -0,0 +1,24 @@
+package subway.config.constants.initValues;
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum Lines {
+ LINE_2("2호선", Arrays.asList("교대역", "강남역", "역삼역")),
+ LINE_3("3호선", Arrays.asList("교대역", "남부터미널역", "양재역","매봉역")),
+ 신분당선("신분당선", Arrays.asList("강남역", "양재역", "양재시민의숲역"));
+ private String name;
+ private List values;
+ Lines(String name, List values){
+ this.name = name;
+ this.values=values;
+ }
+
+ public String getName(){
+ return this.name;
+ }
+
+ public List getValues(){
+ return this.values;
+ }
+}
diff --git a/src/main/java/subway/config/constants/initValues/StationName.java b/src/main/java/subway/config/constants/initValues/StationName.java
new file mode 100644
index 000000000..e4c65d08f
--- /dev/null
+++ b/src/main/java/subway/config/constants/initValues/StationName.java
@@ -0,0 +1,7 @@
+package subway.config.constants.initValues;
+
+public enum StationName {
+ 교대역, 강남역, 역삼역, 남부터미널역, 양재역, 양재시민의숲역, 매봉역;
+
+ private String station;
+}
diff --git a/src/main/java/subway/config/constants/views/Errors.java b/src/main/java/subway/config/constants/views/Errors.java
new file mode 100644
index 000000000..e9532b78c
--- /dev/null
+++ b/src/main/java/subway/config/constants/views/Errors.java
@@ -0,0 +1,18 @@
+package subway.config.constants.views;
+
+public enum Errors {
+ VALID("잘못된 명령입니다. 입력값을 확인해주세요."),
+ ADD_STATION("이미 등록된 역 이름입니다."),
+ ADD_LINE("이미 등록된 노선 이름입니다."),
+ DEL_STATION("존재하지 않은 역 이름입니다."),
+ UNEXPECTED("예상치 못한 에러가 발생했습니다."),
+ DEL_LINE("존재하지 않는 노선 이름입니다.");
+
+ private final String message;
+ Errors(String message){
+ this.message = message;
+ }
+ public String getError(){
+ return this.message;
+ }
+}
diff --git a/src/main/java/subway/config/constants/views/Indexes.java b/src/main/java/subway/config/constants/views/Indexes.java
new file mode 100644
index 000000000..209faf549
--- /dev/null
+++ b/src/main/java/subway/config/constants/views/Indexes.java
@@ -0,0 +1,46 @@
+package subway.config.constants.views;
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum Indexes {
+ MAIN("메인", Arrays.asList("역 관리", "노선 관리", "구간 관리", "지하철 노선도 출력")),
+ METHOD("기능", Arrays.asList("등록", "삭제", "조회"));
+
+ private String role;
+ private List values;
+
+ Indexes(String role, List values) {
+ this.role = role;
+ this.values = values;
+ }
+
+ public String getRole() {
+ return this.role;
+ }
+
+ public String getIndex() {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < values.size(); i++) {
+ sb.append(i + 1).append(". ");
+ sb.append(values.get(i)).append("\n");
+ }
+ sb.append("Q. 종료\n");
+ return sb.toString();
+ }
+
+ public String getIndex(String target) {
+ int size = values.size();
+ if (target.equals("구간")) {
+ size = 2;
+ }
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < size; i++) {
+ sb.append(i + 1).append(". ");
+ sb.append(target).append(" ");
+ sb.append(values.get(i)).append("\n");
+ }
+ sb.append("B. 돌아가기\n");
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/subway/config/constants/views/Methods.java b/src/main/java/subway/config/constants/views/Methods.java
new file mode 100644
index 000000000..9fa3c28ee
--- /dev/null
+++ b/src/main/java/subway/config/constants/views/Methods.java
@@ -0,0 +1,18 @@
+package subway.config.constants.views;
+
+public enum Methods {
+ 등록("1"),
+ 삭제("2"),
+ 조회("3"),
+ 출력("4"),
+ 종료("Q"),
+ 돌아가기("B");
+ private final String command;
+ Methods(String command){
+ this.command = command;
+ }
+
+ public String getCommand(){
+ return command;
+ }
+}
diff --git a/src/main/java/subway/config/constants/views/Prefixes.java b/src/main/java/subway/config/constants/views/Prefixes.java
new file mode 100644
index 000000000..a47710333
--- /dev/null
+++ b/src/main/java/subway/config/constants/views/Prefixes.java
@@ -0,0 +1,14 @@
+package subway.config.constants.views;
+
+public enum Prefixes {
+ SHARP("## "),
+ INFO("[INFO] "),
+ ERROR("[ERROR] ");
+ private final String prefix;
+ Prefixes(String prefix){
+ this.prefix=prefix;
+ }
+ public String getPrefix(){
+ return this.prefix;
+ }
+}
diff --git a/src/main/java/subway/config/constants/views/Questions.java b/src/main/java/subway/config/constants/views/Questions.java
new file mode 100644
index 000000000..5fac64e59
--- /dev/null
+++ b/src/main/java/subway/config/constants/views/Questions.java
@@ -0,0 +1,32 @@
+package subway.config.constants.views;
+
+public enum Questions {
+ FUNC("원하는 기능을 선택하세요.\n"),
+ NAME("을 입력하세요.\n"),
+ SEQUENCE("순서를 입력하세요.\n");
+
+ private final String question;
+ static final String SHARP = Prefixes.SHARP.getPrefix();
+
+ Questions(String question) {
+ this.question = question;
+ }
+
+ public String Message(){
+ StringBuilder sb = new StringBuilder();
+ sb.append(SHARP).append(this.question);
+ return sb.toString();
+ }
+
+ public String Message(String target) {
+ StringBuilder sb= new StringBuilder();
+ sb.append(SHARP);
+ sb.append(target).append(this.question);
+ return sb.toString();
+ }
+
+ public String Message(String work, String target) {
+ String message = work + "할 " + target + this.question;
+ return message;
+ }
+}
diff --git a/src/main/java/subway/config/constants/views/Targets.java b/src/main/java/subway/config/constants/views/Targets.java
new file mode 100644
index 000000000..f9c049ee9
--- /dev/null
+++ b/src/main/java/subway/config/constants/views/Targets.java
@@ -0,0 +1,25 @@
+package subway.config.constants.views;
+
+public enum Targets {
+ STATION("역", 1),
+ LINE("노선",2),
+ SECTION("구간", 3),
+ MAP("지하철 노선도", 4),
+ UPPER("상행 종점역", 5),
+ BOTTOM("하행 종점역", 6);
+
+ private final String target;
+ private final int command;
+ Targets(String target, int command){
+ this.target = target;
+ this.command=command;
+ }
+
+ public String getTarget(){
+ return this.target;
+ }
+
+ public int getCommand(){
+ return this.command;
+ }
+}
diff --git a/src/main/java/subway/config/handler/InputExceptionError.java b/src/main/java/subway/config/handler/InputExceptionError.java
new file mode 100644
index 000000000..3bb8ecfdc
--- /dev/null
+++ b/src/main/java/subway/config/handler/InputExceptionError.java
@@ -0,0 +1,26 @@
+package subway.config.handler;
+
+import subway.config.constants.views.Prefixes;
+
+public class InputExceptionError extends RuntimeException{
+ public enum ErrorMessage{
+ PUT_VAILD_VALUE("유효한 범위 내의 명령어를 입력해주세요."),
+ PUT_ONLY_VAILD_NUMBER("자연수만 입력 가능합니다."),
+ PUT_UNDER_4_OR_Q_VALUE("4 이하 자연수나 Q만 입력 가능합니다."),
+ CAN_NOT_CHOICE_THIS_FUNCTION("선택할 수 없는 기능입니다."),
+ THERE_IS_NO_SUCH_STATION("존재하지 않은 역입니다."),
+ THERE_IS_NO_SUCH_LINE("존재하지 않은 노선입니다."),
+ THERE_IS_AREADY_THE_SAME_STATION("이미 생성된 역입니다."),
+ THERE_IS_AREADY_THE_SAME_LINE("이미 생성된 노선입니다.");
+
+ private final String message;
+ private final static String prefix=Prefixes.ERROR.getPrefix();
+ ErrorMessage(String message){
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return prefix+message;
+ }
+ }
+}
diff --git a/src/main/java/subway/config/handler/SubwayException.java b/src/main/java/subway/config/handler/SubwayException.java
new file mode 100644
index 000000000..a06e48c75
--- /dev/null
+++ b/src/main/java/subway/config/handler/SubwayException.java
@@ -0,0 +1,53 @@
+package subway.config.handler;
+
+import subway.config.constants.views.Errors;
+import subway.config.constants.views.Prefixes;
+
+import static subway.config.handler.InputExceptionError.ErrorMessage.*;
+
+public class SubwayException extends RuntimeException {
+ private static String ERROR = Prefixes.ERROR.getPrefix();
+
+ public boolean isNotNumber(){
+ throw new NumberFormatException(PUT_ONLY_VAILD_NUMBER.getMessage());
+ }
+
+ public boolean isNotUnder4OrQ(){
+ throw new IllegalArgumentException(PUT_UNDER_4_OR_Q_VALUE.getMessage());
+ }
+
+ public void notValidCommand() {
+ throw new IllegalArgumentException(PUT_VAILD_VALUE.getMessage());
+ }
+
+
+
+ public void unexpected(){
+ throw new IllegalArgumentException(ERROR+Errors.UNEXPECTED.getError());
+ }
+ public boolean isBack(String command){
+ if(command.equals('B')){
+ return true;
+ }
+ return false;
+ }
+
+ public void checkCommand() {
+ throw new IllegalArgumentException(ERROR+ Errors.VALID.getError());
+ }
+
+ public boolean alreadyCreatedLine(){
+ throw new IllegalArgumentException(THERE_IS_AREADY_THE_SAME_LINE.getMessage());
+ }
+ public boolean alreadyCreatedStation(){
+ throw new IllegalArgumentException(THERE_IS_AREADY_THE_SAME_STATION.getMessage());
+ }
+
+ public boolean noStation() {
+ throw new IllegalArgumentException(THERE_IS_NO_SUCH_STATION.getMessage());
+ }
+
+ public void noLine() {
+ throw new IllegalArgumentException(THERE_IS_NO_SUCH_LINE.getMessage());
+ }
+}
diff --git a/src/main/java/subway/controller/LineController.java b/src/main/java/subway/controller/LineController.java
new file mode 100644
index 000000000..3205aef46
--- /dev/null
+++ b/src/main/java/subway/controller/LineController.java
@@ -0,0 +1,72 @@
+package subway.controller;
+
+import subway.config.handler.SubwayException;
+import subway.service.InitManager;
+import subway.service.LineManager;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+public class LineController extends ManageController {
+ static LineManager lineManager;
+ private static SubwayException subwayException;
+
+ public LineController(final InitManager manager) {
+ lineManager = manager.getLineManager();
+ subwayException = manager.getSubwayException();
+ }
+
+ @Override
+ public boolean register() {
+ String upper, bottom, message;
+ try {
+ String line = method.getLine(REGISTER, LINE);
+ if (lineManager.isEmpty(line) != true) {
+ subwayException.alreadyCreatedLine();
+ }
+
+ upper = method.getStation(lineManager, REGISTER, UPPER);
+ bottom = method.getStation(lineManager, REGISTER, BOTTOM);
+ if(upper == null || bottom == null){
+ subwayException.noStation();
+ }
+
+ lineManager.setStations(line, upper, bottom);
+ } catch (Exception e) {
+ message= makeString.infoMessage(REGISTER, LINE,false);
+ System.out.println(message);
+ e.printStackTrace();
+ subwayException.unexpected();
+ }
+ message= makeString.infoMessage(REGISTER, LINE, true);
+ System.out.println(message);
+ return true;
+ }
+
+ @Override
+ public boolean delete() {
+ String message;
+ boolean result=false;
+ // 노선 db 에서 삭제
+ ask.orderWhere(DELETE, LINE);
+ try {
+ String command = br.readLine();
+ result = lineManager.delete(command);
+ message=makeString.infoMessage(DELETE,LINE, result);
+ } catch (Exception e) {
+ message=makeString.infoMessage(DELETE,LINE, result);
+ System.out.println(message);
+ subwayException.noLine();
+ return false;
+ }
+ System.out.println(message);
+ return true;
+ }
+
+ public boolean read() {
+ response.printTitle("지하철 노선도");
+ StringBuilder list = lineManager.read();
+ response.printList(list);
+ return true;
+ }
+}
diff --git a/src/main/java/subway/controller/MainController.java b/src/main/java/subway/controller/MainController.java
new file mode 100644
index 000000000..8d675b1d2
--- /dev/null
+++ b/src/main/java/subway/controller/MainController.java
@@ -0,0 +1,88 @@
+package subway.controller;
+
+import subway.config.handler.SubwayException;
+import subway.controller.utils.Constants;
+import subway.service.InitManager;
+import subway.view.AskView;
+
+import java.io.IOException;
+
+import static subway.controller.ManageController.br;
+
+public class MainController implements Constants {
+ private AskView ask;
+ private StationController stationController;
+ private LineController lineController;
+ private SectionController sectionController;
+ private MapController mapController;
+ private static SubwayException subwayException;
+ private static int command;
+
+
+ public MainController() {
+ ask = new AskView();
+ InitManager manager = new InitManager();
+ setControllers(manager);
+ subwayException = manager.getSubwayException();
+ }
+
+ public void setControllers(InitManager manager) {
+ stationController = new StationController(manager);
+ lineController = new LineController(manager);
+ sectionController = new SectionController(manager);
+ mapController = new MapController(manager);
+ }
+
+ public void headController() throws Exception {
+ while (true) {
+ ask.printMain();
+ String node = br.readLine();
+ if (isEnd(node)) return;
+ nextStep(node);
+ }
+ }
+
+ public boolean isEnd(String node) throws IOException {
+ if (node.equals("Q") || node.equals("q")) {
+ System.out.println(" 안녕히 가세요. ");
+ br.close();
+ return true;
+ }
+ return false;
+ }
+
+ public void nextStep(String node) {
+ try {
+ if (!strToInt(node)) return;
+ CoreController(command);
+ } catch (SubwayException e) {
+ subwayException.isNotUnder4OrQ();
+ }
+ }
+
+ public boolean CoreController(int command) {
+ if (command == STATION_COMMAND) {
+ return stationController.work(stationController, STATION);
+ }
+ if (command == LINE_COMMAND) {
+ return lineController.work(lineController, LINE);
+ }
+ if (command == SECTION_COMMAND) {
+ return sectionController.work(sectionController, SECTION);
+ }
+ if (command == MAP_COMMAND) {
+ return mapController.work();
+ }
+ throw new SubwayException();
+ }
+
+ public boolean strToInt(final String node) {
+ try {
+ command = Integer.parseInt(node);
+ return true;
+ } catch (NumberFormatException e) {
+ subwayException.isNotUnder4OrQ();
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/subway/controller/ManageController.java b/src/main/java/subway/controller/ManageController.java
new file mode 100644
index 000000000..3053d8fef
--- /dev/null
+++ b/src/main/java/subway/controller/ManageController.java
@@ -0,0 +1,43 @@
+package subway.controller;
+
+import subway.controller.utils.Constants;
+import subway.controller.utils.Controller;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import static subway.controller.StationController.subwayException;
+
+public abstract class ManageController implements Controller, Constants {
+ protected static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+ public boolean work(final Controller controller, final String target) {
+ ask.WhatToManage(target);
+ ask.Function();
+ try {
+ String command = br.readLine();
+ sendRequest(controller, command);
+ } catch (Exception e) {
+ subwayException.checkCommand();
+ }
+ return false;
+ }
+
+ // 등록하기
+ public boolean sendRequest(final Controller controller, final String command) {
+ if (command.equals(REGISTER_COMMAND)) {
+ return controller.register();
+ }
+ if (command.equals(DELETE_COMMAND)) {
+ return controller.delete();
+ }
+ if (command.equals(READ_COMMAND)) {
+ return controller.read();
+ }
+ if (command.equals(BACK_COMMAND)) {
+ return true;
+ }
+ subwayException.notValidCommand();
+ return false;
+ }
+}
diff --git a/src/main/java/subway/controller/MapController.java b/src/main/java/subway/controller/MapController.java
new file mode 100644
index 000000000..4a23a561c
--- /dev/null
+++ b/src/main/java/subway/controller/MapController.java
@@ -0,0 +1,18 @@
+package subway.controller;
+
+import subway.service.InitManager;
+import subway.service.LineManager;
+
+public class MapController {
+ static LineManager lineManager;
+ MapController(InitManager manager){
+ lineManager = manager.getLineManager();
+ }
+ public boolean work(){
+ printMap();
+ return true;
+ }
+ public void printMap(){
+ System.out.println(lineManager.getStationLines());
+ }
+}
diff --git a/src/main/java/subway/controller/SectionController.java b/src/main/java/subway/controller/SectionController.java
new file mode 100644
index 000000000..8607f4022
--- /dev/null
+++ b/src/main/java/subway/controller/SectionController.java
@@ -0,0 +1,68 @@
+package subway.controller;
+
+import subway.config.handler.SubwayException;
+import subway.controller.utils.Controller;
+import subway.service.InitManager;
+import subway.service.SectionManager;
+
+public class SectionController extends ManageController {
+ private static SectionManager sectionManager;
+ static SubwayException subwayException;
+
+ public SectionController(final InitManager manager){
+ sectionManager = manager.getSectionManager();
+ subwayException = manager.getSubwayException();
+ }
+
+ @Override
+ public boolean sendRequest(final Controller controller, final String command){
+ if (command.equals(REGISTER_COMMAND)) { // 등록
+ return controller.register();
+ }
+ if (command.equals(DELETE_COMMAND)) { // 삭제
+ return controller.delete();
+ }
+ if (command.equals(BACK_COMMAND)) { // 되돌아가기
+ return true;
+ }
+ subwayException.notValidCommand();
+ return false;
+ }
+
+ @Override
+ public boolean register() { // 노선, 역 이름, 순서 입력 받고 등록
+ String line = method.getLine();
+ if(!sectionManager.isEmpty(line)){
+ return false;
+ }
+
+ String station = method.getStation();
+ int index = method.getIndex();
+ if(index == -1){
+ return false;
+ }
+
+ sectionManager.insertSection(station, index);
+ response.printInfo("구간이 등록되었습니다.");
+ return true;
+ }
+
+ @Override
+ public boolean delete() {
+ try{
+ String line = method.getLine(DELETE, "구간의 노선");
+ String station = method.getStation(sectionManager, DELETE, "구간의 역");
+
+ if(sectionManager.isEmpty(line)){
+ sectionManager.delete(station);
+ response.printInfo("구간이 삭제되었습니다.");
+ }
+ } catch (Exception e){
+ subwayException.unexpected();
+ return false;
+ }
+ return true;
+ }
+ @Override
+ public boolean read() {return false;}
+}
diff --git a/src/main/java/subway/controller/StationController.java b/src/main/java/subway/controller/StationController.java
new file mode 100644
index 000000000..1a5abd711
--- /dev/null
+++ b/src/main/java/subway/controller/StationController.java
@@ -0,0 +1,57 @@
+package subway.controller;
+
+import subway.config.handler.SubwayException;
+import subway.service.InitManager;
+import subway.service.StationManager;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+// 역을 관리하는 컨트롤러
+public class StationController extends ManageController{
+ static StationManager stationManager;
+ static SubwayException subwayException;
+
+ StationController(final InitManager manager){
+ stationManager = manager.getStationManager();
+ subwayException = manager.getSubwayException();
+ }
+
+ @Override
+ public boolean register(){
+ ask.orderWhere(REGISTER, STATION);
+ try {
+ String station = br.readLine();
+ boolean result = stationManager.isEmpty(station);
+ String message = makeString.infoMessage(REGISTER, STATION,result);
+ response.printInfo(message);
+ return false;
+ }catch (Exception e){
+ e.printStackTrace();
+ subwayException.unexpected();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean delete(){
+ ask.orderWhere(DELETE, STATION);
+ try {
+ String command = br.readLine();
+ boolean result = stationManager.delete(command);
+ String message = makeString.infoMessage(DELETE, STATION, result);
+ response.printInfo(message);
+ }catch (Exception e){
+ subwayException.unexpected();
+ return false;
+ }
+ return true;
+ }
+
+ public boolean read(){
+ response.printTitle("역 목록");
+ StringBuilder list = stationManager.read();
+ response.printList(list);
+ return true;
+ }
+}
diff --git a/src/main/java/subway/controller/utils/Constants.java b/src/main/java/subway/controller/utils/Constants.java
new file mode 100644
index 000000000..4907562ef
--- /dev/null
+++ b/src/main/java/subway/controller/utils/Constants.java
@@ -0,0 +1,32 @@
+package subway.controller.utils;
+
+import subway.config.constants.views.Methods;
+import subway.config.constants.views.Targets;
+import subway.view.AskView;
+import subway.view.ResponseView;
+import subway.view.util.MakeString;
+
+public interface Constants {
+ static final String REGISTER_COMMAND = Methods.등록.getCommand();
+ static final String DELETE_COMMAND = Methods.삭제.getCommand();
+ static final String READ_COMMAND = Methods.조회.getCommand();
+ static final String BACK_COMMAND = Methods.돌아가기.getCommand();
+
+ static final String REGISTER = Methods.등록.toString();
+ static final String DELETE = Methods.삭제.toString();
+
+ static final String STATION = Targets.STATION.getTarget();
+ static final String LINE = Targets.LINE.getTarget();
+ static final String UPPER = Targets.UPPER.getTarget();
+ static final String BOTTOM = Targets.BOTTOM.getTarget();
+ static final String SECTION = Targets.SECTION.getTarget();
+
+ static final int STATION_COMMAND = Targets.STATION.getCommand();
+ static final int LINE_COMMAND = Targets.LINE.getCommand();
+ static final int SECTION_COMMAND = Targets.SECTION.getCommand();
+ static final int MAP_COMMAND = Targets.MAP.getCommand();
+
+ static final AskView ask = new AskView();
+ static final ResponseView response = new ResponseView();
+ static final MakeString makeString = new MakeString();
+}
diff --git a/src/main/java/subway/controller/utils/Controller.java b/src/main/java/subway/controller/utils/Controller.java
new file mode 100644
index 000000000..519b293a8
--- /dev/null
+++ b/src/main/java/subway/controller/utils/Controller.java
@@ -0,0 +1,13 @@
+package subway.controller.utils;
+
+import subway.view.AskView;
+import subway.view.ResponseView;
+import subway.view.util.MakeString;
+
+public interface Controller {
+ static final Methods method = new Methods();
+
+ public boolean register();
+ public boolean delete();
+ public boolean read();
+}
diff --git a/src/main/java/subway/controller/utils/Methods.java b/src/main/java/subway/controller/utils/Methods.java
new file mode 100644
index 000000000..909e6dacc
--- /dev/null
+++ b/src/main/java/subway/controller/utils/Methods.java
@@ -0,0 +1,77 @@
+package subway.controller.utils;
+
+import subway.config.handler.SubwayException;
+import subway.controller.StationController;
+import subway.service.Managerable;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import static subway.service.utils.Constants.subwayException;
+
+public class Methods implements Constants {
+ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ public Methods() {}
+
+ public int getIndex() {
+ ask.orderWhere();
+ try {
+ String input = br.readLine();
+ if (subwayException.isBack(input) == true) return -1;
+ int index = Integer.parseInt(input);
+ return index;
+ } catch (SubwayException e) {
+ e.isNotNumber();
+ } catch (Exception e) {
+ subwayException.checkCommand();
+ }
+ return -1;
+ }
+
+ public String getLine() {
+ ask.orderWhere(LINE);
+ try {
+ String line = br.readLine();
+ return line;
+ } catch (Exception e) {
+ subwayException.checkCommand();
+ }
+ return null;
+ }
+
+ public String getLine(String function, String target) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ ask.orderWhere(function, target);
+ return br.readLine();
+ } catch (Exception e) {
+ subwayException.checkCommand();
+ }
+ return null;
+ }
+
+ public String getStation() {
+ ask.orderWhere("역 이름");
+
+ try {
+ return br.readLine();
+ } catch (Exception e) {
+ subwayException.noStation();
+ }
+ return null;
+ }
+
+ public String getStation(Managerable manager, String function, String station) {
+ try {
+ ask.orderWhere(function, station);
+ String node = br.readLine();
+ if (manager.isEmpty(node) != true) {
+ subwayException.noStation();
+ }
+ return node;
+ } catch (Exception e) {
+ subwayException.unexpected();
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/subway/domain/Line.java b/src/main/java/subway/domain/Line.java
index f4d738d5a..f7ebefa14 100644
--- a/src/main/java/subway/domain/Line.java
+++ b/src/main/java/subway/domain/Line.java
@@ -1,15 +1,59 @@
package subway.domain;
+import java.util.LinkedList;
+
public class Line {
private String name;
+ private LinkedList stations = new LinkedList<>();
- public Line(String name) {
+ public Line(final String name) {
this.name = name;
}
public String getName() {
return name;
}
+ public StringBuilder stationList(){
+ StringBuilder sb = new StringBuilder();
+ for(Station station:stations){
+ sb.append("[INFO] "+station.getName()).append("\n");
+ }
+ return sb;
+ }
+
+ public void setStations(final Station upper, final Station bottom) {
+ stations.addFirst(upper);
+ stations.addLast(bottom);
+ }
+
+ public void addStation(final Station station, final int index) {
+ if(index==0){
+ stations.addFirst(station);
+ return;
+ }
+ if(index==stations.size()){
+ stations.addLast(station);
+ return;
+ }
+ stations.add(index-1, station);
+ }
- // 추가 기능 구현
+ public boolean deleteStation(final String station) {
+ for (int index = 0; index < stations.size(); index++) {
+ Station s = stations.get(index);
+ if (s.getName().equals(station)) {
+ stations.remove(index);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int getSize(){
+ return this.stations.size();
+ }
+
+ public Station getStation(int index){
+ return this.stations.get(index);
+ }
}
diff --git a/src/main/java/subway/domain/LineRepository.java b/src/main/java/subway/domain/LineRepository.java
index 49132ddb6..727b4ada3 100644
--- a/src/main/java/subway/domain/LineRepository.java
+++ b/src/main/java/subway/domain/LineRepository.java
@@ -12,11 +12,24 @@ public static List lines() {
return Collections.unmodifiableList(lines);
}
- public static void addLine(Line line) {
+ public static void addLine(final Line line) {
lines.add(line);
}
- public static boolean deleteLineByName(String name) {
- return lines.removeIf(line -> Objects.equals(line.getName(), name));
+ public static void addLine(final Line line, final Station station, final int index) {
+ line.addStation(station, index);
+ }
+
+ public static boolean deleteLineByName(final String name) {
+ return lines.removeIf(line -> Objects.equals(line.getName(), name) && line.getSize()>2);
+ }
+
+ public static Line getLineByName(final String name) {
+ for (Line line : lines) {
+ if (line.getName().equals(name)) {
+ return line;
+ }
+ }
+ return null;
}
}
diff --git a/src/main/java/subway/domain/Station.java b/src/main/java/subway/domain/Station.java
index bdb142590..413c6ddaf 100644
--- a/src/main/java/subway/domain/Station.java
+++ b/src/main/java/subway/domain/Station.java
@@ -1,15 +1,40 @@
package subway.domain;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
public class Station {
private String name;
+ private List line = new LinkedList();
+ private int canDelete=0;
- public Station(String name) {
+ public Station(final String name) {
this.name = name;
}
public String getName() {
- return name;
+ return this.name;
+ }
+ public void addLine(Line lineNode){
+ line.add(lineNode);
+ }
+ public void deleteLine(Line lineNode){
+ line.remove(lineNode);
+ }
+
+ public boolean hasNoLine(){
+ if(canDelete==0){
+ return true;
+ }
+ return false;
+ }
+
+ public void canDelete(){
+ this.canDelete-=1;
}
- // 추가 기능 구현
+ public void neverDelete(){
+ this.canDelete+=1;
+ }
}
diff --git a/src/main/java/subway/domain/StationRepository.java b/src/main/java/subway/domain/StationRepository.java
index b7245c0f3..7a64e2633 100644
--- a/src/main/java/subway/domain/StationRepository.java
+++ b/src/main/java/subway/domain/StationRepository.java
@@ -16,7 +16,15 @@ 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 deleteStation(final String name) {
+ return stations.removeIf(station -> Objects.equals(station.getName(), name) && station.hasNoLine());
+ }
+ public static Station getStationByName(final String name){
+ for(Station station : stations){
+ if(station.getName().equals(name)){
+ return station;
+ }
+ }
+ return null;
}
}
diff --git a/src/main/java/subway/service/InitManager.java b/src/main/java/subway/service/InitManager.java
new file mode 100644
index 000000000..eccbc489c
--- /dev/null
+++ b/src/main/java/subway/service/InitManager.java
@@ -0,0 +1,72 @@
+package subway.service;
+
+import subway.config.constants.initValues.*;
+import subway.config.handler.SubwayException;
+import subway.domain.Line;
+import subway.domain.Station;
+import subway.service.utils.Constants;
+
+import java.util.List;
+
+
+public class InitManager implements Constants {
+
+ public LineManager getLineManager(){
+ return lineManager;
+ }
+
+ public static StationManager getStationManager() {
+ return stationManager;
+ }
+
+ public static SectionManager getSectionManager(){
+ return sectionManager;
+ }
+ public static SubwayException getSubwayException(){return subwayException;}
+
+ public InitManager(){
+ // 초기값 삽입
+ addStations();
+ addLines();
+ }
+
+ public void addStations(){
+ StationName[] names = StationName.values();
+ for(StationName name: names){
+ String station = name.toString();
+ stationRepo.addStation(new Station(station));
+ }
+ }
+
+ public void addLines(){
+ Lines[] lines = Lines.values();
+ for(Lines line : lines){
+ Line node = initLine(line);
+ lineRepo.addLine(node);
+ }
+ }
+
+ public Line initLine(final Lines line){
+ Line node = new Line(line.getName());
+ List values = line.getValues();
+
+ for(int i =0 ;i < values.size();i++){
+ String station = values.get(i);
+ node = addStation(node, station, i);
+ }
+
+ return node;
+ }
+
+ public Line addStation(Line line , final String value, final int index ){
+ Station station = stationRepo.getStationByName(value);
+ station.addLine(line);
+ line.addStation(station, index);
+ if(line.getSize()<=2){
+ station.neverDelete();
+ return line;
+ }
+ station.canDelete();
+ return line;
+ }
+}
diff --git a/src/main/java/subway/service/LineManager.java b/src/main/java/subway/service/LineManager.java
new file mode 100644
index 000000000..66c29c1f3
--- /dev/null
+++ b/src/main/java/subway/service/LineManager.java
@@ -0,0 +1,72 @@
+package subway.service;
+
+import subway.config.handler.SubwayException;
+import subway.domain.Line;
+import subway.domain.Station;
+import subway.service.utils.LineMakeString;
+
+import java.util.List;
+
+import static subway.service.InitManager.*;
+
+public class LineManager implements Managerable {
+ LineMakeString makeString = new LineMakeString();
+ SubwayException subwayException = new SubwayException();
+ @Override
+ public boolean isEmpty(final String name) {
+ if(subwayException.isBack(name)){
+ return false;
+ }
+ if(lineRepo.getLineByName(name) == null){
+ return true;
+ }
+ return false;
+ }
+
+ public Line setLine(final String name){
+ Line node = new Line(name);
+ lineRepo.addLine(node);
+ return node;
+ }
+
+ public void setStations(final String name, final String upperStation, final String bottomStation){
+ Line line = setLine(name);
+ Station upper = stationManager.getByName(upperStation);
+ Station bottom = stationManager.getByName(bottomStation);
+ upper.addLine(line);
+ bottom.addLine(line);
+ line.setStations(upper, bottom);
+ }
+
+ @Override
+ public boolean delete(final String name) {
+ Line line = lineRepo.getLineByName(name);
+ for(int i=0;i lineList = lineRepo.lines();
+ for(Line line:lineList){
+ String rail = line.getName();
+ String title = makeString.title(rail);
+ sb.append(title);
+ sb.append(line.stationList()).append("\n");
+ }
+ return sb;
+ }
+}
diff --git a/src/main/java/subway/service/Managerable.java b/src/main/java/subway/service/Managerable.java
new file mode 100644
index 000000000..f336ca05c
--- /dev/null
+++ b/src/main/java/subway/service/Managerable.java
@@ -0,0 +1,7 @@
+package subway.service;
+
+public interface Managerable {
+ public boolean isEmpty(final String command);
+ public boolean delete(final String name);
+ public StringBuilder read();
+}
diff --git a/src/main/java/subway/service/SectionManager.java b/src/main/java/subway/service/SectionManager.java
new file mode 100644
index 000000000..43e935e36
--- /dev/null
+++ b/src/main/java/subway/service/SectionManager.java
@@ -0,0 +1,44 @@
+package subway.service;
+
+import subway.config.handler.SubwayException;
+import subway.domain.Line;
+import subway.domain.Station;
+
+import static subway.service.InitManager.lineRepo;
+import static subway.service.InitManager.stationRepo;
+
+public class SectionManager implements Managerable {
+ private Line line;
+ SubwayException subwayException = new SubwayException();
+ @Override
+ public boolean isEmpty(final String name) {
+ if(subwayException.isBack(name) == true)
+ return false;
+
+ line = lineRepo.getLineByName(name);
+
+ if(line == null)
+ subwayException.noLine();
+ return true;
+ }
+
+ public void insertSection(final String sName,final int index){
+ Station station = stationRepo.getStationByName(sName);
+ if(station == null) subwayException.noStation();
+ lineRepo.addLine(line, station, index);
+ }
+
+ @Override
+ public boolean delete(final String name) {
+ if(subwayException.isBack(name) == true) return true;
+ if(line.deleteStation(name)) return true;
+ subwayException.checkCommand();
+ return false;
+ }
+
+ @Override
+ public StringBuilder read() {
+ StringBuilder sb = new StringBuilder();
+ return sb;
+ }
+}
diff --git a/src/main/java/subway/service/StationManager.java b/src/main/java/subway/service/StationManager.java
new file mode 100644
index 000000000..c00468bbe
--- /dev/null
+++ b/src/main/java/subway/service/StationManager.java
@@ -0,0 +1,40 @@
+package subway.service;
+
+import subway.config.handler.SubwayException;
+import subway.domain.Station;
+import static subway.service.InitManager.stationRepo;
+
+// 역 관련 기능하는 서비스
+public class StationManager implements Managerable {
+ @Override // 삽입
+ public boolean isEmpty(final String name) {
+ if(stationRepo.getStationByName(name)!=null){
+ // TODO: 이미 존재하는 역
+ throw new SubwayException();
+ }
+ stationRepo.addStation(new Station(name));
+ return true;
+ }
+ @Override
+ public boolean delete(final String name) {
+ return stationRepo.deleteStation(name);
+ }
+
+ @Override
+ public StringBuilder read() {
+ StringBuilder sb = new StringBuilder();
+ for(Station station : stationRepo.stations()){
+ sb.append("[INFO] " + station.getName()+"\n");
+ }
+ return sb;
+ }
+
+ public Station getByName(final String name){
+ try{
+ isEmpty(name);
+ }catch (SubwayException e){
+ e.alreadyCreatedStation();
+ }
+ return stationRepo.getStationByName(name);
+ }
+}
diff --git a/src/main/java/subway/service/utils/Constants.java b/src/main/java/subway/service/utils/Constants.java
new file mode 100644
index 000000000..8b2644267
--- /dev/null
+++ b/src/main/java/subway/service/utils/Constants.java
@@ -0,0 +1,20 @@
+package subway.service.utils;
+
+import subway.config.handler.SubwayException;
+import subway.domain.LineRepository;
+import subway.domain.StationRepository;
+import subway.service.LineManager;
+import subway.service.SectionManager;
+import subway.service.StationManager;
+
+public interface Constants {
+ static final LineRepository lineRepo = new LineRepository();
+ static final StationRepository stationRepo = new StationRepository();
+
+ static final StationManager stationManager = new StationManager();
+ static final SectionManager sectionManager = new SectionManager();
+ static final LineManager lineManager = new LineManager();
+
+ static final SubwayException subwayException = new SubwayException();
+
+}
diff --git a/src/main/java/subway/service/utils/LineMakeString.java b/src/main/java/subway/service/utils/LineMakeString.java
new file mode 100644
index 000000000..469d0fd67
--- /dev/null
+++ b/src/main/java/subway/service/utils/LineMakeString.java
@@ -0,0 +1,20 @@
+package subway.service.utils;
+
+import subway.config.constants.views.Prefixes;
+
+public class LineMakeString {
+ String INFO = Prefixes.INFO.getPrefix();
+ public String title(final String rail){
+ StringBuilder sb= new StringBuilder();
+ sb.append(INFO).append(rail).append("\n");
+ sb.append(INFO).append("---").append("\n");
+ return sb.toString();
+ }
+
+ public String lines(final String name){
+ StringBuilder sb = new StringBuilder();
+ sb.append(INFO);
+ sb.append(name);
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/subway/view/AskView.java b/src/main/java/subway/view/AskView.java
new file mode 100644
index 000000000..69adc5e2c
--- /dev/null
+++ b/src/main/java/subway/view/AskView.java
@@ -0,0 +1,40 @@
+package subway.view;
+
+import subway.view.util.Constants;
+import subway.view.util.MakeString;
+
+public class AskView implements Constants { // TODO: (고민) view 가 너무 중구난방인 거 같은데 controller, service 처럼 분할할까.
+ static final MakeString makeString = new MakeString();
+
+ public void printMain() {
+ System.out.println(makeString.showTitle(MAIN));
+ System.out.println(makeString.showIndex(MAIN));
+ }
+
+ public void WhatToManage(final String target) {
+ System.out.println(makeString.showTitle(target));
+ System.out.println(makeString.showIndex(target));
+ }
+
+ //"원하는 기능을 선택하세요."
+ public void Function() {
+ System.out.println(makeString.askFunction());
+ }
+
+ //## 등록/삭제할 역/노선을 입력하세요
+ public void orderWhere(final String work, final String name) {
+ String sentence = makeString.askName(work, name);
+ System.out.println(sentence);
+ }
+
+ // 역/노선을 입력하세요
+ public void orderWhere(final String name) {
+ String sentence = makeString.askName(name);
+ System.out.println(sentence);
+ }
+
+ public void orderWhere() { // 등록 or 삭제
+ System.out.println(makeString.askSequence());
+ }
+
+}
diff --git a/src/main/java/subway/view/ResponseView.java b/src/main/java/subway/view/ResponseView.java
new file mode 100644
index 000000000..182e32c5a
--- /dev/null
+++ b/src/main/java/subway/view/ResponseView.java
@@ -0,0 +1,22 @@
+package subway.view;
+
+import subway.view.util.Constants;
+
+public class ResponseView implements Constants {
+ public void printInfo(final String message){
+ StringBuilder sb = new StringBuilder();
+ sb.append(INFO).append(message);
+ System.out.println(sb);
+ sb.setLength(0);
+ }
+
+ public void printTitle(final String title){
+ StringBuilder sb = new StringBuilder();
+ sb.append(SHARP).append(title);
+ System.out.println(sb);
+ sb.setLength(0);
+ }
+ public void printList(final StringBuilder message){
+ System.out.println(message);
+ }
+}
diff --git a/src/main/java/subway/view/util/Constants.java b/src/main/java/subway/view/util/Constants.java
new file mode 100644
index 000000000..84e92d1fc
--- /dev/null
+++ b/src/main/java/subway/view/util/Constants.java
@@ -0,0 +1,17 @@
+package subway.view.util;
+
+import subway.config.constants.views.Indexes;
+import subway.config.constants.views.Prefixes;
+import subway.config.constants.views.Questions;
+
+public interface Constants {
+ static final String SHARP = Prefixes.SHARP.getPrefix();
+ static final String INFO = Prefixes.INFO.getPrefix();
+ static final Indexes METHOD = Indexes.METHOD;
+ static final Questions SEQUENCE = Questions.SEQUENCE;
+ static final Questions TARGET = Questions.NAME;
+ static final Questions FUNC = Questions.FUNC;
+ static final String MAIN = Indexes.MAIN.getRole();
+ static final String MAIN_INDEX = Indexes.MAIN.getIndex();
+
+}
diff --git a/src/main/java/subway/view/util/MakeString.java b/src/main/java/subway/view/util/MakeString.java
new file mode 100644
index 000000000..7ecb14a41
--- /dev/null
+++ b/src/main/java/subway/view/util/MakeString.java
@@ -0,0 +1,57 @@
+package subway.view.util;
+
+public class MakeString implements Constants{
+ // ## ~~ 화면
+ public String showTitle(final String title){
+ return getTitle(MAIN, title);
+ }
+
+ public String getTitle(final String role, final String title){
+ StringBuilder sb = new StringBuilder();
+ if(title.equals(role)){
+ sb.append(SHARP).append(title);
+ sb.append(" 화면");
+ return sb.toString();
+ }
+ sb.append(SHARP).append(title);
+ sb.append("관리 화면");
+ return sb.toString();
+ }
+
+ public String showIndex(final String target){
+ if(target.equals(MAIN)){
+ return MAIN_INDEX;
+ }
+
+ return METHOD.getIndex(target);
+ }
+ public String infoMessage(final String work, final String target, final boolean result){
+ StringBuilder sb = new StringBuilder();
+ sb.append("지하철 ").append(target).append("이 ");
+ if(result == true){
+ sb.append(work).append("되었습니다.");
+ }
+ if(result == false){
+ sb.append(work).append("되지 않았습니다. 연결된 노선이나 해당 노선에 속한 역을 확인해주세요.");
+ }
+ return sb.toString();
+ }
+
+ // 노선/역이름 을 입력하세요.
+ public String askName(final String target){
+ return TARGET.Message(target);
+ }
+
+ // 등록/삭제할 노선/역이름 을 입력하세요.
+ public String askName(final String work, final String name){
+ return TARGET.Message(work, name);
+ }
+
+ public String askFunction(){
+ return FUNC.Message();
+ }
+
+ public String askSequence(){
+ return SEQUENCE.Message();
+ }
+}