Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a3adea7
docs(README) : 전체적인 구현 리스트 생성
hybeom0720 Dec 12, 2020
9d40650
feat(Station) : 지하철 역 기능 구현
hybeom0720 Dec 12, 2020
815e2fd
feat(StationRepository) : 지하철 역 리스트 구현
hybeom0720 Dec 12, 2020
cb3f574
feat(Line) : 지하철 노선 구현
hybeom0720 Dec 12, 2020
25fe858
feat(LineRepository) : 지하철 노선 리스트 구현
hybeom0720 Dec 12, 2020
83b3d9d
feat(InputViewer) : Input에 관한 Viewer 구현
hybeom0720 Dec 12, 2020
ba5518a
feat(OutputViewer) : Output에 관한 Viewer 구현
hybeom0720 Dec 13, 2020
a099e30
docs(README) : Error case 추가 및 객체 추가
hybeom0720 Dec 13, 2020
2e46875
feat(Initiator) : Initiator 및 SubwaySystem 추가
hybeom0720 Dec 13, 2020
f2274d4
fix(Order) : 각각의 Repository에 정렬 기능 추가
hybeom0720 Dec 13, 2020
d83ef5a
feat(StationManager) : 역 관련 기능을 관리하는 Controller를 추가하였습니다.
hybeom0720 Dec 14, 2020
559730b
feat(LineManager) : 호선 관리에 대한 프로그램, $LineManager 및 관련 객체 추가
hybeom0720 Dec 14, 2020
f9d3f0a
feat(IntervalManager) : 구간 관리에 대한 프로그램, IntervalManager 및 관련 객체 추가
hybeom0720 Dec 14, 2020
53bc231
feat(EntireManager) : 전체 노선도를 보여주는 객체 추가
hybeom0720 Dec 14, 2020
11a0bf5
feat(EntireSystem) : 전체 프로그램 관리하는 $EntireSystem 추가
hybeom0720 Dec 14, 2020
0763825
refactor : Constants 정리
hybeom0720 Dec 14, 2020
c204380
fix(Controller) : 에러 발생시 메세지 및 귀환 체계 수정
hybeom0720 Dec 14, 2020
9d577fe
fix(main) : Origin Repository로부터 바뀐 사항 pull
hybeom0720 Dec 14, 2020
616de33
docs(README) : 에러 발생 케이스 및 예외 사항 추가
hybeom0720 Dec 14, 2020
bad65f2
fix(error) : 에러 발생 케이스 및 예외 다루기.
hybeom0720 Dec 15, 2020
e7503a9
refactor : 코드 정렬
hybeom0720 Dec 15, 2020
2211fec
fix(StationRepository) : 역 삭제 유효성 체크 변경
hybeom0720 Dec 15, 2020
5ac0a1b
docs(README) : 문서 기능 업데이트
hybeom0720 Dec 15, 2020
1c51298
fix(ErrorMessage) : ErrorMessage에 관련된 Viewer 개선
hybeom0720 Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Subway System

## Entire System
1. 지하철 역 Model 생성 및 오류 체크, 이름 조회 기능 추가.
2. 지하철 역 리스트 생성 및 오류 체크, 중복 체크 기능 추가.
a. 해당하는 이름의 역이 포함되어 있는지 체크
3. 지하철 노선 생성 및 오류, 이름 조회 기능 추가.
a. 노선에 특정 역이 속해져있는지 체크.
b. 노선에 포함된 역의 갯수 체크
4. 지하철 노선 리스트 생성 및 오류 체크. 중복 체크 기능 추가.
a. 산하 노선들의 이름 체크
5. 입력값에 대한 InputViewer 추가.
6. 결과값에 대한 OutputViewer 추가.
7. Initiator 및 전체 시스템 관리자 생성
8. 역 관리 Controller 생성.
a. 등록 및 삭제 시, 두 글자 이상인[역]으로 끝나는지 유효성 체크
b. 등록 시, 해당하는 역이 등록이 되어 있는지 체크
c. 삭제 시, 전체 역 리스트에서 들어가있는지 유효성 체크
d. 삭제 시, 해당하는 역이 2개의 역만으로 구성되어있는 노선에 들어가 있는지 체크
e. 삭제 시, 노선에 등록되어 있는지에 대한 유효성 체크
9. 노선 관리 Controller 생성.
a. 등록 및 삭제 시, [역] 및 [선]으로 끝나는지 유효성 체크
b. 등록 및 삭제시 이미 등록된 노선인지 체크
c. 등록 시 역이 등록이 되어있는지 체크
d. 등록 시 출발역과 종착역 중복 입력됬는지 체크
10. 구간 관리 Controller 생성.
a. 등록 및 삭제 시, [역] 및 [선]으로 끝나는지 유효성 체크
b. 등록 및 삭제 시, 해당 노선 및 역이 존재하는지 체크
c. 등록 시, 이미 등록된 역인지 체크
d. 등록 시, 순서가 밖으로 나가는지 체크
e. 삭제 시, 2개 미만으로 떨어지는지 유효성 체크
11. 지하철 노선도 출력 Controller 생성.
12. 전체 관리 Controller 생성.

### SubwaySystem
- 전체 관리하는 시스템
- 생성 시에 기본 요구 조건 맞추면서 시작
- 번호를 받으면 처리

### domain
#### Station
- 지하철역 생성 및 생성 시 오류 체크.
- 2글자 이상이야 한다.
- 지하철역 이름 보여주기.
#### StationRepository
- 지하철역 모음 중복 체크 해주기.
- 지하철역 전체 리스트에서 삭제 및 추가.
- 역 등록시에 순서 정렬
- 역 삭제시 노선에서도 전체 삭제, 노선이 역을 가진 갯수가 2개 미만 발생시 삭제 취소
#### Line
- 지하철 노선 생성 및 생성 시 오류 체크.
- 2글자 이상이야 한다.
- 노선에 지하철역 추가 및 삭제.
- 중복된 역이 들어가 있으지 확인.
- 노선 안 지하철 역 삭제시 최소 2개의 역 있는지 확인.
- 노선에 등록 전 역이 실제로 등록되어 있는지 확인
#### LineRepository
- 노선 모음 및 중복 체크 해주기.
- 노선 등록시 순서 정렬
- 노선 자체에 중복이 있으면 안된다.
- 노선 전체 리스트에서 삭제 및 추가.
#### Constants
- domain에서 자주 쓰이는 상수 모음

### Viewer
#### SystemInputViewer
- 전체 시스템 관련 인풋을 받아오는 객체.
#### StationInputViewer
- 역 관련 인풋 받아오는 객체.
#### LineInputViewer
- 노선 관련 인풋 받아오는 객체.
#### IntervalInputViewer
- 구간 관련 인풋을 받아오는 객체.
#### StationOutputViewer
- 역 관련 아웃풋을 보여주는 객체.
#### LineOutputViewer
- 노선 관련 아웃풋을 보여주는 객체.
#### IntervalOutputViewer
- 구간 관련 아웃풋을 보여주는 객체.
#### SystemOutputViewer
- 전체 시스템 관련 아웃풋을 보여주는 객체.
#### Constants
- Viewer에서 자수 쓰이는 상수 모음


### Controller
공통적으로 Input을 받을 시에 해당 항목 벗어나면 Error 발생.
각각의 컨트롤러의 경우, Set, Sector, Unit 순으로 세부 기능이 쪼개지게 됨.
#### EntireSystem
- 전체 시스템을 관장하는 객체.
#### Initiator
- 초기 값들을 생성해주는 객체.
#### StationManager
- 역 관리를 맡고 있는 객체.
#### LineManager
- 노선 관리를 맡고 있는 객체.
#### IntervalManager
- 구간 관리를 맡고 있는 객체.
#### EntireShowManager
- 전체 노선을 보여주는 객체.
#### Constants
- Controller에서 자주 쓰이는 상수 모음

3 changes: 2 additions & 1 deletion src/main/java/subway/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class Application {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
// TODO: 프로그램 구현
SubwaySystem subwaySystem = new SubwaySystem(scanner);
subwaySystem.process();
}
}
20 changes: 20 additions & 0 deletions src/main/java/subway/SubwaySystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package subway;

import subway.controller.EntireSystem;
import subway.controller.Initiator;

import java.util.Scanner;

public class SubwaySystem {
private final Scanner scanner;

SubwaySystem(Scanner scanner) {
Initiator.intiate();
this.scanner = scanner;
}

public void process() {
EntireSystem entireSystem = new EntireSystem(scanner);
entireSystem.runProgram();
}
}
47 changes: 47 additions & 0 deletions src/main/java/subway/controller/EntireSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package subway.controller;

import subway.controller.constants.QuestionNumber;

import java.util.Scanner;

public enum EntireSet {
STATION(QuestionNumber.ONE.getOption()) {
public void processSet(Scanner scanner) {
StationManager stationManager = new StationManager(scanner);
stationManager.processSector();
}
},
LINE(QuestionNumber.TWO.getOption()) {
public void processSet(Scanner scanner) {
LineManager lineManager = new LineManager(scanner);
lineManager.processSector();
}
},
INTERVAL(QuestionNumber.THREE.getOption()) {
public void processSet(Scanner scanner) {
IntervalManager intervalManager = new IntervalManager(scanner);
intervalManager.processSector();
}
},
ENTIRE_MAP(QuestionNumber.FOUR.getOption()) {
public void processSet(Scanner scanner) {
EntireShowManager entireShowManager = new EntireShowManager();
entireShowManager.processSector();
}
},
QUIT(QuestionNumber.TERMINATE.getOption()) {
public void processSet(Scanner scanner) {}
};

private String option;

private EntireSet(String option) {
this.option = option;
}

abstract public void processSet(Scanner scanner);

public String getOption() {
return option;
}
}
10 changes: 10 additions & 0 deletions src/main/java/subway/controller/EntireShowManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package subway.controller;

import subway.domain.LineRepository;
import subway.viewer.EntireMapOutputViewer;

public class EntireShowManager {
public void processSector() {
EntireMapOutputViewer.showEntireMap(LineRepository.lines());
}
}
52 changes: 52 additions & 0 deletions src/main/java/subway/controller/EntireSystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package subway.controller;

import subway.controller.constants.QuestionNumber;
import subway.controller.constants.SelectOptionConstants;
import subway.viewer.SystemInputViewer;

import java.util.Scanner;

public class EntireSystem {
private Scanner scanner;

public EntireSystem(Scanner scanner) {
this.scanner = scanner;
}

public void runProgram() {
String sector;
do {
SystemInputViewer.askMainScreen();
sector = scanner.nextLine();
isValidSector(sector);
goSector(sector);
} while (!sector.equals(QuestionNumber.TERMINATE.getOption()));
}

private void isValidSector(String sector) {
try {
isContainSectorList(sector);
} catch (Exception error) {
System.out.println();
System.out.println(SelectOptionConstants.OPTION_ERROR);
}
}

private void isContainSectorList(String sector) {
if (!SelectOptionConstants.ENTIRE_SECTOR.contains(sector)) {
throw new IllegalArgumentException(SelectOptionConstants.OPTION_ERROR);
}
}

private void goSector(String sector) {
for (EntireSet entireOption : EntireSet.values()) {
filterSector(entireOption, scanner, sector);
}
}

private void filterSector(EntireSet candidate, Scanner scanner, String option) {
if (candidate.getOption().equals(option)) {
candidate.processSet(scanner);
}
}
}
64 changes: 64 additions & 0 deletions src/main/java/subway/controller/Initiator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package subway.controller;

import subway.controller.constants.InitialNewBoonDangLine;
import subway.controller.constants.InitialSecondLine;
import subway.controller.constants.InitialStations;
import subway.controller.constants.InitialThirdLine;
import subway.domain.Line;
import subway.domain.LineRepository;
import subway.domain.Station;
import subway.domain.StationRepository;

public class Initiator {
private static final String SECOND_LINE = "2호선";
private static final String THIRD_LINE = "3호선";
private static final String NEW_BOONDANG_LINE = "신분당선";

public static void intiate() {
initiateStation();
initiateLine();
}

private static void initiateLine() {
initiateSecondLine();
initiateThirdLine();
initiateNewBoonDangLine();
}

private static void initiateSecondLine() {
Line secondLine = new Line(SECOND_LINE);
for (InitialSecondLine eachStation : InitialSecondLine.values()) {
int order = eachStation.getOrder();
Station insertedStation = new Station(eachStation.getName());
secondLine.insertStation(order, insertedStation);
}
LineRepository.addLine(secondLine);
}

private static void initiateThirdLine() {
Line thirdLine = new Line(THIRD_LINE);
for (InitialThirdLine eachStation : InitialThirdLine.values()) {
int order = eachStation.getOrder();
Station insertedStation = new Station(eachStation.getName());
thirdLine.insertStation(order, insertedStation);
}
LineRepository.addLine(thirdLine);
}

private static void initiateNewBoonDangLine() {
Line newBoonDangLine = new Line(NEW_BOONDANG_LINE);
for (InitialNewBoonDangLine eachStation : InitialNewBoonDangLine.values()) {
int order = eachStation.getOrder();
Station insertedStation = new Station(eachStation.getName());
newBoonDangLine.insertStation(order, insertedStation);
}
LineRepository.addLine(newBoonDangLine);
}

private static void initiateStation() {
for (InitialStations initialStation : InitialStations.values()) {
Station insertedStation = new Station(initialStation.getName());
StationRepository.addStation(insertedStation);
}
}
}
53 changes: 53 additions & 0 deletions src/main/java/subway/controller/IntervalManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package subway.controller;

import subway.controller.constants.SelectOptionConstants;
import subway.viewer.IntervalInputViewer;

import java.util.Scanner;

public class IntervalManager {
private Scanner scanner;

IntervalManager(Scanner scanner) {
this.scanner = scanner;
}

public void processSector() {
boolean happenedError;
do {
IntervalInputViewer.askMainScreen();
happenedError = checkSectorStatus();
} while (happenedError);
}

private boolean checkSectorStatus() {
try {
String unit = scanner.nextLine();
isValidUnit(unit);
goUnit(scanner, unit);
return false;
} catch (Exception error) {
return true;
}
}

private void isValidUnit(String unit) {
if (!SelectOptionConstants.INTERVAL_OPTION.contains(unit)) {
System.out.println();
System.out.println(SelectOptionConstants.OPTION_ERROR);
throw new IllegalArgumentException(SelectOptionConstants.OPTION_ERROR);
}
}

private void goUnit(Scanner scanner, String unit) {
for (IntervalSectors intervalSector : IntervalSectors.values()) {
filterUnit(intervalSector, scanner, unit);
}
}

private void filterUnit(IntervalSectors candidate, Scanner scanner, String unit) {
if (candidate.getOption().equals(unit)) {
candidate.processUnit(scanner);
}
}
}
Loading