[java-baseball] yohan.kim(김요한) 과제 제출합니다.#2
Open
yohanii wants to merge 12 commits intoJapring-Study:yohan/java-baseballfrom
Open
[java-baseball] yohan.kim(김요한) 과제 제출합니다.#2yohanii wants to merge 12 commits intoJapring-Study:yohan/java-baseballfrom
yohanii wants to merge 12 commits intoJapring-Study:yohan/java-baseballfrom
Conversation
swandevson
reviewed
Sep 26, 2024
Comment on lines
+1
to
+8
| # 기능 목록 | ||
|
|
||
| - [x] 게임 관리 - GameManager class | ||
| - [x] 게임 시작 - start() | ||
| - [x] 숫자 야구 구현 - BaseballGame class | ||
| - [x] 세 자리수 랜덤 숫자 생성 - generateAnswer() | ||
| - [x] 사용자 입력 받기 - receiveUserInput() | ||
| - [x] 사용자 숫자를 받아 채점 및 정답 여부 반환 - score() No newline at end of file |
There was a problem hiding this comment.
각 기능에 대한 예외사항과 핸들링도 기재되면 좋을 것 같습니다!
Comment on lines
+41
to
+52
| public int receiveUserInput() { | ||
| System.out.print("숫자를 입력해주세요 : "); | ||
|
|
||
| String input = Console.readLine(); | ||
| validateInput(input); | ||
|
|
||
| try { | ||
| return Integer.parseInt(input); | ||
| } catch (NumberFormatException e) { | ||
| throw new IllegalArgumentException("잘못된 입력 형식입니다."); | ||
| } | ||
| } |
Comment on lines
+29
to
+31
| while (numbers.size() < 3) { | ||
| numbers.add(Randoms.pickNumberInRange(1, 9)); | ||
| } |
There was a problem hiding this comment.
3, 1, 9와 같은 숫자를 상수로 선언해 사용하시는건 어떨까요?
Comment on lines
+93
to
+96
| if (strike == 3) { | ||
| System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료"); | ||
| return true; | ||
| } |
There was a problem hiding this comment.
출력과 boolean값 return을 동시에 해서 두가지 일을 하는 것 처럼 보입니다
외부에서 ture/false에 따라 출력 여부를 결정하도록 변경하면 어떨까요?
|
|
||
| public class BaseballGame { | ||
|
|
||
| private Integer answer; |
Member
Author
There was a problem hiding this comment.
의도는 generateAnswer()에서 answer에 값을 넣어주는 부분이 있는데,
int 자료형이면 값 참조를 못해서, 값이 안들어갈까봐 Integer로 설정해주었습니다!
그런데, 찾아보니까 int여도 값이 잘 들어간다고 하네요ㅠ
int로 바꾸는게 더 좋을 것 같습니다.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[java-baseball] yohan.kim(김요한) 과제 제출합니다.