Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
112 changes: 112 additions & 0 deletions src/main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# 예상 시나리오
1. 기능 선택 보기를 출력한다.
2. 기능 선택 입력을 받는다.
1) 1을 입력받은 경우 (페어 매칭)
1) 과정, 미션을 출력한다.
2) 과정, 미션, 레벨을 입력 받는다.
* 이미 매칭 결과가 있을 경우, 재매칭 여부를 묻는다.
* 네 -> 2-i-c로 가서 재매칭 결과를 출력한다.
* 아니오 -> 2-i-b로 돌아간다.
* 올바르지 않은 값을 입력한 경우, 에러 메시지를 출력하고 다시 입력 받는다.
3) 매칭 결과를 출력한다.
4) 1로 돌아간다.
2) 2를 입력한다. (페어 조회)
1) 과정, 미션을 출력한다.
2) 과정, 미션, 레벨을 입력 받는다.
* 매칭 결과가 있을 경우, 기존에 존재하는 해당 매칭 결과를 출력한다.
* 없을 경우, 없음을 고지하고 1로 돌아간다.
* 올바르지 않은 값을 입력한 경우, 에러 메시지를 출력하고 다시 입력 받는다.
3) 3을 입력한다. (페어 초기화)
1) 초기화되었음을 출력한다.
4) Q를 입력한다. (종료)
1) 프로그램을 종료한다.
5) 이 외의 값을 입력한다.
1) 에러 메시지를 출력하고 다시 입력 받는다.

### 예외 처리
1. 기능 선택 시, 주어진 1, 2, 3, Q 외 값을 입력한다.
2. 과정, 미션, 레벨 입력 시, 주어진 보기 외 값을 입력한다.

# 구현 기능 목록

### 기능 선택 보기를 입력 받는 기능

- [x] "기능을 선택하세요.\n1. 페어 매칭\n2. 페어 조회\n3. 페어 초기화\nQ. 종료"를 출력한다.
- [x] 값을 입력 받는다.
- [x] 입력값을 검증한다.
- [x] 1, 2, 3, Q 중에 하나인가?

### 크루원 목록 생성 기능

- [x] backend-crews.md 파일을 읽는다.
- [x] 내용을 List<String> 변수에 담는다.
- [x] frontend-crews.md 파일을 읽는다.
- [x] 내용을 List<String> 변수에 담는다.

### 페어 매칭 기능

- [x] "#############################################\n

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리드미도 어쨌든 개발자가 직접 관리해야 하는 자원이기 때문에 추후 변경이 있으면 직접 변경해야 합니다. 때문에 출력값또한 언제든지 변경될 수 있기에 너무 구체적으로 적기보단, "미션 출력 기능" 이런식으로 간단하게 적는게 좋다고 들었어요!

과정: [과정 목록]\n
미션:\n
\- 레벨1: [미션 목록]\n
\- 레벨2: [미션 목록]\n
\- 레벨3: [미션 목록]\n
\- 레벨4: [미션 목록]\n
\- 레벨5: [미션 목록]\n
############################################\n
과정, 레벨, 미션을 선택하세요.\n
ex) 백엔드, 레벨1, 자동차경주"를 출력한다.
- [x] 과정, 레벨, 미션을 입력 받는다.
- [x] 입력값을 검증한다.
- [x] 과정, 레벨, 미션으로 파싱한다.
- [x] 과정이 존재하는가?
- [x] 레벨이 존재하는가?
- [x] 미션이 존재하는가?
- [x] 기존 매칭 결과가 있을 경우,
- [x] "매칭 정보가 있습니다. 다시 매칭하시겠습니까?\n 네 | 아니오"를 출력한다.
- [x] 값을 입력 받는다.
- [x] "네" -> 아래의 "새로운 매칭 결과를 출력하는 경우"로 넘어간다.
- [x] "아니오" -> "과정, 레벨, 미션 입력"으로 돌아간다.
- [x] 새로운 매칭 결과를 출력하는 경우,
- [x] 각 과정에 맞는 크루원 이름을 셔플한다.
- [x] 결과를 저장한다.
- [x] 매칭 결과를 출력한다.
- [x] "페어 매칭 결과입니다."를 출력한다.
- [x] 한 줄에 두 명씩 묶어 "[이름] : [이름]" 형태로 출력한다.
- [x] 크루원이 홀수일 경우, 마지막 3명을 한 페어로 묶어 출력한다.
- [x] 기능 선택으로 돌아간다.

### 페어 조회 기능

- [x] "#############################################\n
과정: [과정 목록]\n
미션:\n
\- 레벨1: [미션 목록]\n
\- 레벨2: [미션 목록]\n
\- 레벨3: [미션 목록]\n
\- 레벨4: [미션 목록]\n
\- 레벨5: [미션 목록]\n
############################################\n
과정, 레벨, 미션을 선택하세요.\n
ex) 백엔드, 레벨1, 자동차경주"를 출력한다.
- [x] 과정, 레벨, 미션을 입력 받는다.
- [x] 입력값을 검증한다.
- [x] 과정, 레벨, 미션으로 파싱한다.
- [x] 과정이 존재하는가?
- [x] 레벨이 존재하는가?
- [x] 미션이 존재하는가?
- [x] 기존 매칭 결과가 존재하는 경우,
- [x] 매칭 결과를 출력한다.
- [x] 매칭 결과가 존재하지 않을 경우,
- [x] "매칭 이력이 없습니다."를 출력한다.
- [x] 기능 선택으로 돌아간다.

### 페어 초기화 기능

- [x] 매칭 결과를 모두 삭제한다.
- [x] "초기화 되었습니다."를 출력한다.
- [x] 기능 선택으로 돌아간다.

### 종료 기능

- [x] Q를 입력받을 경우, 프로그램을 종료한다.
5 changes: 4 additions & 1 deletion src/main/java/pairmatching/Application.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package pairmatching;

import pairmatching.controller.Controller;

public class Application {
public static void main(String[] args) {
// TODO 구현 진행
Controller controller = new Controller();
controller.run();
}
}
7 changes: 7 additions & 0 deletions src/main/java/pairmatching/config/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package pairmatching.config;

public class Config {

public static final String BACKEND_CREW_FILE = "src/main/resources/backend-crew.md";
public static final String FRONTEND_CREW_FILE = "src/main/resources/backend-crew.md";
}
6 changes: 6 additions & 0 deletions src/main/java/pairmatching/constant/Constant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package pairmatching.constant;

public class Constant {

public static final int MAX_TRY = 5;
}
76 changes: 76 additions & 0 deletions src/main/java/pairmatching/controller/Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package pairmatching.controller;

import static pairmatching.constant.Constant.MAX_TRY;
import static pairmatching.exception.ExceptionMessage.MAX_TRY_ERROR;
import static pairmatching.exception.ExceptionMessage.NO_FUNCTION_ERROR;
import static pairmatching.view.ErrorPrinter.printError;

import pairmatching.domain.Pairs;
import pairmatching.exception.PairmatchingException;
import pairmatching.service.PairCheckService;
import pairmatching.service.PairMatchingService;
import pairmatching.service.PairResetService;
import pairmatching.view.InputView;

public class Controller {

private static Pairs pairs = new Pairs();

private static final String PAIR_MATCHING_FUNC = "1";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1,2,3,Q 이러한 값들을 Enum 으로 관리하면 편하더라구요!

private static final String PAIR_CHECK_FUNC = "2";
private static final String PAIR_RESET_FUNC = "3";
private static final String PAIR_QUIT_FUNC = "Q";

public void run() {
boolean running = true;
while (running) {
String functionInput = readFunction();
if (functionInput.equals(PAIR_MATCHING_FUNC)) {
PairMatchingService pairMatchingService = new PairMatchingService(pairs);
pairMatchingService.operate();
continue;
}
if (functionInput.equals(PAIR_CHECK_FUNC)) {
PairCheckService pairCheckService = new PairCheckService(pairs);
try {
pairCheckService.operate();
continue;
} catch (PairmatchingException e) {
printError(e.getMessage());
}
}
if (functionInput.equals(PAIR_RESET_FUNC)) {
PairResetService pairResetService = new PairResetService(pairs);
pairs = pairResetService.operate();
continue;
}
if (functionInput.equals(PAIR_QUIT_FUNC)) {
running = false;
}
}
}

private String readFunction() {
for (int i = 1; i <= MAX_TRY; i++) {
try {
String input = InputView.readFunction();
if (isValidInput(input)) {
return input;
}
} catch (IllegalArgumentException e) {
printError(e.getMessage());
}
}
throw new PairmatchingException(MAX_TRY_ERROR);
}

private boolean isValidInput(String input) {
if (input.equals(PAIR_MATCHING_FUNC)
|| input.equals(PAIR_CHECK_FUNC)
|| input.equals(PAIR_RESET_FUNC)
|| input.equals(PAIR_QUIT_FUNC)) {
return true;
}
throw new PairmatchingException(NO_FUNCTION_ERROR);
}
}
38 changes: 38 additions & 0 deletions src/main/java/pairmatching/domain/Course.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package pairmatching.domain;

import static pairmatching.config.Config.BACKEND_CREW_FILE;
import static pairmatching.config.Config.FRONTEND_CREW_FILE;
import static pairmatching.exception.ExceptionMessage.NO_COURSE;

import pairmatching.exception.PairmatchingException;

public enum Course {

BACKEND("백엔드", BACKEND_CREW_FILE),
FRONTEND("프론트엔드", FRONTEND_CREW_FILE);

private final String name;
private final String filePath;

Course(final String name, final String filePath) {
this.name = name;
this.filePath = filePath;
}

public String getName() {
return name;
}

public String getFilePath() {
return filePath;
}

public static Course fromName(String name) {
for (Course course : values()) {
if (course.getName().equals(name)) {
return course;
}
}
throw new PairmatchingException(NO_COURSE);
}
}
26 changes: 26 additions & 0 deletions src/main/java/pairmatching/domain/CrewNameList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package pairmatching.domain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import pairmatching.repository.CrewNameRepository;

public class CrewNameList {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클래스 네이밍에 List,Set 과같은 자료 타입이 들어가는걸 조심해야 합니다(클린코드)


private static Map<Course, List<String>> crewNames;

public static List<String> getNames(Course course) {
if (crewNames == null) {
initializeCrewNames();
}
return crewNames.get(course);
}

private static void initializeCrewNames() {
crewNames = new HashMap<>();
CrewNameRepository crewNameRepository = new CrewNameRepository();
for (Course course : Course.values()) {
crewNames.put(course, crewNameRepository.loadCrew(course));
}
}
}
33 changes: 33 additions & 0 deletions src/main/java/pairmatching/domain/Level.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package pairmatching.domain;

import static pairmatching.exception.ExceptionMessage.NO_LEVEL;

import pairmatching.exception.PairmatchingException;

public enum Level {

LEVEL1("레벨1"),
LEVEL2("레벨2"),
LEVEL3("레벨3"),
LEVEL4("레벨4"),
LEVEL5("레벨5");

private final String name;

Level(String name) {
this.name = name;
}

public String getName() {
return name;
}

public static Level fromName(String name) {
for (Level level : values()) {
if (level.getName().equals(name)) {
return level;
}
}
throw new PairmatchingException(NO_LEVEL);
}
}
44 changes: 44 additions & 0 deletions src/main/java/pairmatching/domain/Mission.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package pairmatching.domain;

import static pairmatching.domain.Level.LEVEL1;
import static pairmatching.domain.Level.LEVEL2;
import static pairmatching.domain.Level.LEVEL4;
import static pairmatching.exception.ExceptionMessage.NO_MISSION;

import pairmatching.exception.PairmatchingException;

public enum Mission {

RACINGCAR("자동차경주", LEVEL1),
LOTTO("로또", LEVEL1),
BASEBALL("숫자야구게임", LEVEL1),
CART("장바구니", LEVEL2),
PAYMENT("결제", LEVEL2),
SUBWAY("지하철노선도", LEVEL2),
IMPROVEMENT("성능개선", LEVEL4),
DEPLOY("배포", LEVEL4);

private final String name;
private final Level level;

Mission(String name, Level level) {
this.name = name;
this.level = level;
}

public String getName() {
return name;
}
public Level getLevel() {
return level;
}

public static Mission fromName(String name) {
for (Mission mission : values()) {
if (mission.getName().equals(name)) {
return mission;
}
}
throw new PairmatchingException(NO_MISSION);
}
}
Loading