-
Notifications
You must be signed in to change notification settings - Fork 53
[4,5단계-사다리] 이지윤 미션 제출합니다. #73
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b6d502c
refactor: 사다리 플레이어 객체 생성 및 검증 추가
dd-jiyun fe94e06
refactor: 패키지 구조 변경
dd-jiyun 0c22e46
docs: step 4 요구사항 수정
dd-jiyun 087c8a1
refactor: 코드 컨벤션 수정
dd-jiyun d76f7f3
refactor: 실행 결과 입력 및 검증 로직 추가
dd-jiyun 7368b28
refactor: 입력 및 출력 로직 수정
dd-jiyun 08faac5
docs: 구현 기능 목록 수정
dd-jiyun cc269c5
refacotor: Player 변경 후 테스트 코드 수정
dd-jiyun 6afa93e
refactor: 디미터 법칙 적용 및 코드 컨벤션에 맞게 수정
dd-jiyun 1286d2d
refactor: 명확한 네이밍으로 변경
dd-jiyun 7c656c3
refactor: 중복된 자료구조 사용 제거
dd-jiyun fd5e48c
refactor: 접근 제어자 추가 및 코드 컨벤션에 맞게 수정
dd-jiyun fcd2ded
refactor: 예외 메세지 일관되게 변경
dd-jiyun 2f45432
refactor: 플레이어 이름 예약어 사용 불가 검증 추가
dd-jiyun 5d58659
refactor: 네이밍 명확하게 변경 및 코드 컨벤션 수정
dd-jiyun 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 hidden or 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 hidden or 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,9 @@ | ||
package constants; | ||
|
||
public final class ReservedWord { | ||
|
||
public static final String FINISH_KEYWORD = "all"; | ||
|
||
private ReservedWord() { | ||
} | ||
} |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,70 @@ | ||
package domain.dto; | ||
|
||
import domain.ladder.Height; | ||
import domain.player.Players; | ||
import domain.runningResult.Results; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
public record RequestLadderGame( | ||
String playerNames, | ||
String runningResults, | ||
String height | ||
) { | ||
|
||
private static final String INPUT_DELIMITER = ","; | ||
|
||
public RequestLadderGame { | ||
validateEmptyPlayerNames(playerNames); | ||
validateEmptyResults(runningResults); | ||
validateEmptyHeight(height); | ||
} | ||
|
||
dd-jiyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private static void validatePlayerCountEqualsResultsCount(final int playerCount, final List<String> results) { | ||
if (playerCount != results.size()) { | ||
throw new IllegalArgumentException("실행 결과 수는 플레이어 수와 동일해야 합니다."); | ||
} | ||
} | ||
|
||
private void validateEmptyPlayerNames(final String playerNames) { | ||
dd-jiyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (playerNames == null || playerNames.isBlank()) { | ||
throw new IllegalArgumentException("플레이어들의 이름은 공백이 아니어야 합니다."); | ||
} | ||
} | ||
|
||
private void validateEmptyResults(final String results) { | ||
if (results == null || results.isBlank()) { | ||
throw new IllegalArgumentException("실행 결과는 공백이 아니어야 합니다."); | ||
} | ||
} | ||
|
||
private void validateEmptyHeight(final String height) { | ||
if (height == null || height.isBlank()) { | ||
throw new IllegalArgumentException("사다리의 높이는 공백이 아니어야 합니다."); | ||
} | ||
} | ||
|
||
public Players toPlayers() { | ||
List<String> names = Stream.of(playerNames.split(INPUT_DELIMITER)) | ||
.map(String::strip) | ||
.toList(); | ||
return Players.from(names); | ||
} | ||
|
||
public Height toHeight() { | ||
try { | ||
return new Height(Integer.parseInt(height.strip())); | ||
} catch (NumberFormatException e) { | ||
throw new IllegalArgumentException("사다리의 높이는 숫자여야 합니다."); | ||
} | ||
} | ||
|
||
public Results toResults(final int playerCount) { | ||
List<String> results = Stream.of(runningResults.split(INPUT_DELIMITER)) | ||
.map(String::strip) | ||
.toList(); | ||
|
||
validatePlayerCountEqualsResultsCount(playerCount, results); | ||
return Results.from(results); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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.
@Choi-JJunho
RequestLadderGame 하나에 모든 입력값을 한 번에 받고 있는데 이 부분에 대해서는 어떻게 생각하시는 지 궁금합니다!
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.
구조 자체에는 문제가 없다고 생각합니다! 하지만 현재 방식으로는 값을 잘못입력한 순간이 아니라 세 값을 모두 입력받았을 때 잘못된 입력인것을 알게되는 구조가 될 것 같은데요!
개인적인 생각으로는 각 입력마다 검증을 해주면 사용자가 더 빠르게 예외를 인지할 수 있을 것 같아요
지금은 입력이 다 끝나야 예외를 알 수 있는 구조네요 :)
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.
맞아요.. 저도 그 부분이 좀 신경 쓰이더라구요!
다음엔 분리해서 빠르게 알 수 있게 해야겠어요 감사합니다 😆