Java baseball game 신채원#9
Hidden character warning
Java baseball game 신채원#9chairoi wants to merge 5 commits intoJava-Spring-Study:java_baseball_game_신채원from
Conversation
|
엇 뭔가 커밋 내용이 branch에 반영이 안된건가요...? 오늘 스터디에서 한번 같이 봐볼게요! |
shkisme
left a comment
There was a problem hiding this comment.
어제 스터디에서 이야기 나왔던 부분들을 다시 한번 코드리뷰로 남겨봅니다! 😎
| baseballgame.Game(); | ||
| loop = input.ifContinue(); | ||
| } | ||
|
|
There was a problem hiding this comment.
말씀 드렸듯이 포메터를 적용해보세요! https://withhamit.tistory.com/411
| while(true) { | ||
| user = input.userNum(); | ||
| strike = answer.countStrike(user); | ||
| ball = answer.countSameNum(user) - strike; |
There was a problem hiding this comment.
필드, 메서드 네이밍을 할 때 축약은 최대한 지양하는게 좋은 것 같아요!
ex) countSameNum -> countSameNumber
src/main/java/baseball/Input.java
Outdated
| int user = scanner.nextInt(); | ||
| return user; | ||
| } | ||
| public boolean ifContinue() { |
There was a problem hiding this comment.
boolean을 반환하는 메서드 네이밍은 is~로 시작하는게 좋습니다!
ex) ifContinue -> isContinue
src/main/java/baseball/Input.java
Outdated
| public boolean ifContinue() { | ||
| System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요."); | ||
| int ifContinue = scanner.nextInt(); | ||
| if (ifContinue == 1) return true; |
There was a problem hiding this comment.
자주 사용하거나, 의미가 명확할 필요가 있는 그런 상수들은, Enum을 활용해서 표현해보세요!
| public class randomInt { | ||
| int number; | ||
|
|
||
| randomInt() { |
There was a problem hiding this comment.
생성자는 클래스를 생성하는 역할만 해도 충분하다고 생각합니다! 생성자에서 랜덤 숫자를 만드는 것 보다, 랜덤 숫자 생성 메서드를 하나 만들어서 이를 활용해 보는 것은 어떨까요?
shkisme
left a comment
There was a problem hiding this comment.
리뷰 드린거 수정하시면 로직이랑 코드에 대해서 더 자세하게 리뷰해드릴게요!
|
|
||
| import java.util.Random; | ||
|
|
||
| public class randomInt { |
src/main/java/baseball/InOut.java
Outdated
|
|
||
| public boolean isContinue() { | ||
| System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요."); | ||
| int ifContinue = scanner.nextInt(); |
| return strike; | ||
| } | ||
|
|
||
| public int countSameNum(int user) { |
src/main/java/baseball/InOut.java
Outdated
|
|
||
| import static baseball.ContinueOrNot.CONTINUE; | ||
|
|
||
| public class InOut { |
There was a problem hiding this comment.
클래스 네이밍이 명확하지 않은 것 같아요. InOut 클래스가 어떤 역할을 하는지 잘 와닿지 않습니다.
No description provided.