-
Notifications
You must be signed in to change notification settings - Fork 709
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
f4b11c4
feat(ladder): rename package util -> generator
mitsui3point 14a8418
refactor(ladder): modify new Random() 상수화 재활용
mitsui3point d672425
refactor(ladder): modify Line break 상수 System.lineSeperator() 로 변경
mitsui3point 5038429
refactor(ladder): modify cross line 출력 문자열
mitsui3point f2dd14b
refactor(ladder): modify cross line 출력 문자열
mitsui3point a9a2dd5
refactor(ladder): modify Point field name current -> right
mitsui3point ebc5785
docs(ladder): add README_LADDER_RUN.md
mitsui3point 5cdc1fb
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 51c30a9
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 89aa3d9
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 72eec73
docs(ladder): modify README_LADDER_RUN.md
mitsui3point e255ccc
docs(ladder): modify README_LADDER_RUN.md
mitsui3point e589be3
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 2070c73
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 9c44efa
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 2151c4d
docs(ladder): modify README_LADDER_RUN.md
mitsui3point b8a8671
feat(ladder): modify Players field playerNames -> players
mitsui3point 1965135
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 94c6c98
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 8b44b4e
docs(ladder): remove step3 added code
mitsui3point 82f8055
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 2ec82e6
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 2284a1e
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 3ecc210
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 2772846
docs(ladder): modify README_LADDER_RUN.md
mitsui3point 4b263f4
feat(ladder): modify unused imports,
mitsui3point 9f5dd51
docs(ladder): modify README_LADDER_RUN.md
mitsui3point File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] 실행 결과들을 출력한다(실행 결과) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. 추상 메서드도 없는데 굳이 추상 클래스로 구현한 이유는? |
||
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍