Open
Conversation
dh2906
reviewed
Mar 31, 2026
Collaborator
There was a problem hiding this comment.
고생하셨습니다! 메소드도 역할 별로 잘 나누셨고, 전체적으로 깔끔하네요 👍
이젠 하나의 파일에 모든 코드가 들어가는 것보다 역할 별로 파일을 분리하는걸 신경써주시면 좋을 듯 싶어요.
커밋도 범위가 너무 커서 앞으로는 기능 하나(입력, 클래스 생성, 우승자 구하기 등등...) 별로 커밋을 작성하시거나, 더 작은 범위로 쪼개주세요!
구글문서 안에 구현한 기능 목록과 작성한 자바 코드가 있습니다.
- 권한 제한 걸려있는데 승인 부탁드립니당
그리고 앞으로도 계속 이런 방식으로 과제를 내는지 궁금합니다.
- 넵 앞으로도 같은 방식으로 과제가 매주 나갈 예정입니다.
- 그러니 매일 시간날 때마다 과제 수행하시는게 훨씬 편할거에요
| * 자동차 이름이 5자를 초과하거나 비어있는지 확인합니다. | ||
| */ | ||
| private static void validateName(String name) { | ||
| if (name.isEmpty() || name.length() > 5) { |
Collaborator
There was a problem hiding this comment.
isEmpty()도 있지만 isBlank()도 있습니다. 둘의 차이는 무엇일까요??
| // 요구 사항: 0에서 9 사이의 무작위 값 구하기 | ||
| int randomNumber = Randoms.pickNumberInRange(0, 9); | ||
| // 요구 사항: 무작위 값이 4 이상일 경우 전진 | ||
| if (randomNumber >= 4) { |
Collaborator
There was a problem hiding this comment.
4 라는 매직 넘버는 상수화를 해주시는게 좋아요
| private static int getMaxPosition(List<Car> cars) { | ||
| int max = 0; | ||
| for (Car car : cars) { | ||
| // 3항 연산자를 쓰지 않기 위해 Math.max 사용 |
Comment on lines
+149
to
+151
| public Car(String name) { | ||
| this.name = name; | ||
| } |
Collaborator
There was a problem hiding this comment.
여기서 자동차의 이름을 검증하는 로직이 들어갈 수도 있지 않을까요?!
물론 이건 정답이 없습니다!
|
|
||
|
|
||
|
|
||
|
|
Comment on lines
+19
to
+36
| // 1. 자동차 이름 입력 및 객체 생성 | ||
| System.out.println("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"); | ||
| String inputNames = Console.readLine(); | ||
| List<Car> cars = createCars(inputNames); | ||
|
|
||
| // 2. 시도 횟수 입력 | ||
| System.out.println("시도할 회수는 몇회인가요?"); | ||
| int tryCount = parseTryCount(Console.readLine()); | ||
|
|
||
| // 3. 경주 진행 및 결과 출력 | ||
| System.out.println("\n실행 결과"); | ||
| for (int i = 0; i < tryCount; i++) { | ||
| playRound(cars); // 한 라운드 진행 | ||
| printRoundResult(cars); // 결과 출력 | ||
| } | ||
|
|
||
| // 4. 최종 우승자 판별 및 출력 | ||
| printFinalWinner(cars); |
Collaborator
There was a problem hiding this comment.
지금도 충분히 메소드를 잘 나누셨지만, 주석에 적어두신대로 각 단계를 메소드 하나로 묶는건 어떻게 생각하시나용
Comment on lines
+84
to
+86
| int randomNumber = Randoms.pickNumberInRange(0, 9); | ||
| // 요구 사항: 무작위 값이 4 이상일 경우 전진 | ||
| if (randomNumber >= 4) { |
Collaborator
There was a problem hiding this comment.
Suggested change
| int randomNumber = Randoms.pickNumberInRange(0, 9); | |
| // 요구 사항: 무작위 값이 4 이상일 경우 전진 | |
| if (randomNumber >= 4) { | |
| if (Randoms.pickNumberInRange(0, 9) >= 4) { |
이렇게하면 randomNumber 변수가 필요 없어져요!
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.
https://docs.google.com/document/d/19UBYJR4N53QwdMdhkpWayIGsIPxRMWOzKYSYdrHvtGo/edit?tab=t.0
구글문서 안에 구현한 기능 목록과 작성한 자바 코드가 있습니다.
그리고 처음으로 코딩 동아리 같은 곳에서 해서 그런지 많이 어렵다고 느꼈습니다.
그리고 앞으로도 계속 이런 방식으로 과제를 내는지 궁금합니다.