-
Notifications
You must be signed in to change notification settings - Fork 11
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
[201800288 채다영] 2주차 미션을 제출합니다. #9
base: main
Are you sure you want to change the base?
Conversation
startGame 함수 생성(자동차 이름과 시도 횟수 입력받고 예외발생시키기)
startGame 함수에 입력할 값을 안내해주는 문장추가
중간과정을 출력하는 printProgress 추가
최종결과를 출력하는 printResult 함수 추가
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.
안녕하세요 다영님!
2차 과제 진행하시느라 고생 많으셨습니다😊😊 아쉽게도 아직 완성은 못하셨지만 그래도 잘 진행해 주셨네요! 기능 목록을 작성하시는 것부터 열심히 구현하려 하셨다는게 잘 보입니다💯💯
커밋도 잘 나누어 주셨고 흐름을 따라가기에도 좋은 것 같아요! 간단한 피드백들 남겨드리니 참고 부탁드립니다!
그럼 남은 기간도 화이팅입니다👊👊
public static void main(String[] args) { | ||
// TODO 구현 진행 | ||
} | ||
public static void startGame() { |
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.
startGame 메소드에서 입력과 예외 처리를 같이 진행하고 있네요! 이는 입력 받기, 게임 실행, 결과 출력 등 책임을 나누어 별도의 메소드나 클래스로 관리할 수 있습니다. 코드를 구현하신 다음 책임을 하나씩 분리해보는 작업을 진행해보시면 어떨까요?
throw new IllegalArgumentException("[ERROR] 시도 횟수는 숫자여야 한다."); | ||
} | ||
} | ||
public void printProgress(Car car) { |
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.
printProgress와 printResult는 선언 방식이 각각 public 과 public static으로 다르네요! 특별한 이유가 있는지 궁금합니다.
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.
실수로 적지 않았습니다ㅎㅎ
try { | ||
attempt = Integer.parseInt(attemptInput); | ||
} catch (NumberFormatException e) { | ||
throw new IllegalArgumentException("[ERROR] 시도 횟수는 숫자여야 한다."); |
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.
잘못된 입력에 대한 예외를 처리해 주셨지만, 사용자에게 재입력을 요청하고 있지 않네요! 이 로직을 추가하여 구현해 주시면 좋을 것 같습니다.
src/main/java/racingcar/Car.java
Outdated
@@ -10,4 +12,16 @@ public Car(String name) { | |||
} | |||
|
|||
// 추가 기능 구현 | |||
public void moveForward() { | |||
int move = Randoms.pickNumberInRange(0,9); | |||
if(move >= 4) { |
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.
moveForward에 사용된 숫자 4는 매직 넘버로 선언하여 관리한다면, 가독성과 유지보수성에 도움을 줍니다. 다음은 예시이니 참고 부탁드립니다!
if(move >= 4) { | |
private static final int MOVE_THRESHOLD = 4 |
} | ||
System.out.println(sb); | ||
} | ||
public static void printResult(List<Car> cars) { |
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.
printResult에는 결과 “출력” 로직만 포함되는 것이 좋습니다. 현재는 우승자를 결정하는 로직까지 포함되어 있음으로 이를 별도의 메소드로 분리해주신다면 더 좋은 코드가 될 것 같습니다!
printProgress에 static 추가
Input 클래스 추가
Input 클래스가 아닌 메서드 추가
InputCarName 메서드 생성 잘못된 입력을 받았을 때 재귀호출로 다시 입력받기
InputAttempt 메서드 생성 잘못된 입력을 받았을 때 재귀호출로 다시 입력받기
indWinners 메서드 생성 우승자 찾기
findWinners 메서드 생성 우승자 찾기
printResult 메서드 수정 우승자 출력
피드백 주신 부분들 반영해서 고쳤보았습니다. |
No description provided.