-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3단계 - 사다리(게임 실행), 2단계 - 사다리(생성) 수정 #2281
Changes from all commits
f4b11c4
14a8418
d672425
5038429
f2dd14b
a9a2dd5
ebc5785
5cdc1fb
51c30a9
89aa3d9
72eec73
e255ccc
e589be3
2070c73
9c44efa
2151c4d
b8a8671
1965135
94c6c98
8b44b4e
82f8055
2ec82e6
2284a1e
3ecc210
2772846
4b263f4
9f5dd51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# 사다리 게임 | ||
## 2단계 - 사다리(생성) | ||
|
||
## 기능 요구사항 | ||
* 사다리 실행 결과를 출력해야 한다. | ||
* 개인별 이름을 입력하면 개인별 결과를 출력하고, "all"을 입력하면 전체 참여자의 실행 결과를 출력한다. | ||
|
||
## 프로그래밍 요구사항 | ||
* 자바 8의 스트림과 람다를 적용해 프로그래밍한다. | ||
* 규칙 6: 모든 엔티티를 작게 유지한다. | ||
* 규칙 7: 3개 이상의 인스턴스 변수를 가진 클래스를 쓰지 않는다. | ||
|
||
### 실행 결과 | ||
* 위 요구사항에 따라 4명의 사람을 위한 5개 높이 사다리를 만들 경우, 프로그램을 실행한 결과는 다음과 같다. | ||
|
||
``` | ||
참여할 사람 이름을 입력하세요. (이름은 쉼표(,)로 구분하세요) | ||
pobi,honux,crong,jk | ||
|
||
실행 결과를 입력하세요. (결과는 쉼표(,)로 구분하세요) | ||
꽝,5000,꽝,3000 | ||
|
||
최대 사다리 높이는 몇 개인가요? | ||
5 | ||
|
||
사다리 결과 | ||
|
||
pobi honux crong jk | ||
|-----| |-----| | ||
| |-----| | | ||
|-----| | | | ||
| |-----| | | ||
|-----| |-----| | ||
꽝 5000 꽝 3000 | ||
|
||
결과를 보고 싶은 사람은? | ||
pobi | ||
|
||
실행 결과 | ||
꽝 | ||
|
||
결과를 보고 싶은 사람은? | ||
all | ||
|
||
실행 결과 | ||
pobi : 꽝 | ||
honux : 3000 | ||
crong : 꽝 | ||
jk : 5000 | ||
``` | ||
|
||
## 힌트 | ||
* 각 로직을 구현하기 위해 필요한 데이터를 가지는 객체를 분리하기 위해 노력해본다. 로직 구현에 필요한 데이터를 가지는 객체를 잘 분리하면 의외로 쉽게 문제를 해결할 수 있다. | ||
* 각 객체가 2개 이하의 인스턴스 변수만을 가지도록 구현해 본다. | ||
|
||
|
||
``` | ||
참여할 사람 이름을 입력하세요. (이름은 쉼표(,)로 구분하세요) | ||
pobi,honux,crong,jk | ||
|
||
/** | ||
없음 | ||
Rewards | ||
List<RewardName> rewards field | ||
*/ | ||
실행 결과를 입력하세요. (결과는 쉼표(,)로 구분하세요) | ||
꽝,5000,꽝,3000 | ||
|
||
최대 사다리 높이는 몇 개인가요? | ||
5 | ||
|
||
사다리 결과 | ||
|
||
pobi honux crong jk | ||
|-----| |-----| | ||
| |-----| | | ||
|-----| | | | ||
| |-----| | | ||
|-----| |-----| | ||
꽝 5000 꽝 3000 // 없음 - Rewards | ||
|
||
/** | ||
없음 - InputView | ||
Name | ||
*/ | ||
결과를 보고 싶은 사람은? | ||
pobi | ||
|
||
/** | ||
없음 - ResultView | ||
Players players; | ||
String result = rewards.result(playerName); | ||
List<String> results = players.results(players); | ||
*/ | ||
실행 결과 | ||
꽝 | ||
|
||
// 없음 - Player | ||
결과를 보고 싶은 사람은? | ||
all | ||
|
||
실행 결과 | ||
pobi : 꽝 | ||
honux : 3000 | ||
crong : 꽝 | ||
jk : 5000 | ||
``` | ||
|
||
## ADDED_TODO | ||
### Domain | ||
* Ladder | ||
- [x] 결과들을 생성한다 | ||
* Rewards | ||
- [x] 생성 | ||
- [x] 생성 실패 | ||
- [x] playersCount 와 일치하지 않으면 실패 | ||
- [x] 이름을 출력한다 | ||
* RewardName extends Name | ||
- [x] 생성 | ||
* Lines | ||
- [x] 플레이어 모두 마지막까지 이동 | ||
* Line | ||
- [x] 플레이어 모두 한칸 아래 이동 | ||
- [x] 플레이어 가로 좌측 이동 | ||
- [x] 플레이어 가로 우측 이동 | ||
- [x] 플레이어 가로 이동 없음 | ||
* Players | ||
- [x] 생성 실패 | ||
- [x] 이름 목록이 1 미만이면 실패 | ||
- [x] 이름목록 출력한다 | ||
- [x] 현재 사다리 높이를 출력한다 | ||
* PlayerName extends Name | ||
- [x] 생성 | ||
* Vertical | ||
- [x] 생성 | ||
- [x] 생성 실패 | ||
- [x] 0 미만이면 생성 실패 | ||
- [x] 이동(무조건 아래로) | ||
* Point | ||
- [x] 이동 | ||
- [x] 좌측 | ||
- [x] 우측 | ||
- [x] 이동안함 | ||
* Results | ||
- [x] 생성 | ||
- [x] 게임결과를 도출한다("pobi") | ||
- [x] 게임결과들을 도출한다("all") | ||
* Map<PlayerName, RewardName> results | ||
### View | ||
* InputView | ||
- [x] 실행 결과를 입력받는다.(실행 결과를 입력하세요. (결과는 쉼표(,)로 구분하세요)) | ||
- [x] 결과를 볼 플레이어 이름을 입력받는다.(결과를 보고 싶은 사람은?) | ||
- [x] 결과를 볼 플레이어 전체를(all) 입력받는다.(결과를 보고 싶은 사람은?) | ||
* ResultView | ||
- [x] 사다리결과에 Rewards 를 붙여 출력한다 | ||
- [x] 실행 결과를 출력한다(실행 결과) | ||
- [x] 실행 결과들을 출력한다(실행 결과) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
import java.util.Objects; | ||
|
||
public class Name { | ||
public abstract class Name { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추상 메서드도 없는데 굳이 추상 클래스로 구현한 이유는? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생각해보니 공통된 메서드가 있는 부분을 추려내서 수정해두겠습니다. |
||
public static final String NOT_ALLOW_EMPTY_NAME_MESSAGE = "이름에 공백이 들어갈 수 없습니다."; | ||
public static final String NOT_ALLOW_EXCEED_MAX_NAME_LENGTH_MESSAGE = "이름을 5글자를 초과할수 없습니다."; | ||
public static final int DEFAULT_MAX_NAME_LENGTH = 5; | ||
|
@@ -20,7 +20,6 @@ public Name(String name) { | |
if (name.length() > MAX_NAME_LENGTH) { | ||
throw new InvalidNameException(NOT_ALLOW_EXCEED_MAX_NAME_LENGTH_MESSAGE); | ||
} | ||
|
||
this.name = name; | ||
} | ||
|
||
|
@@ -44,4 +43,11 @@ public boolean equals(Object o) { | |
public int hashCode() { | ||
return Objects.hash(name); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Name{" + | ||
"name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ladder.domain; | ||
|
||
public class PlayerName extends Name { | ||
public PlayerName(String value) { | ||
super(value); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍