-
Notifications
You must be signed in to change notification settings - Fork 440
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
20221130 자동차경주게임 #510
base: main
Are you sure you want to change the base?
20221130 자동차경주게임 #510
Conversation
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.
코드 잘 봤습니다!
mvc로 나눈 게 인상이 깊네요!
많이 배우고 갑니다!
|
||
import java.util.List; | ||
|
||
public class racingController { |
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.
아! 알려주셔서 감사합니다! 컨벤션 참고해서 수정하도록 하겠습니다 @_@
nameRange(names); | ||
sameName(names); | ||
} catch (IllegalArgumentException e) { | ||
getNames(); |
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.
사용자가 1억번이나 실수하면 프로그램이 터질 것 같습니다!
while 문을 사용해보는건 어떨까요?
아래 예시가 도움이 됬으면 좋겠습니다.
public String[] getNames() {
repeatInputUntilSuccess(() -> {
// 여기에 코드 입력
});
}
private <T> T repeatInputUntilSuccess(Supplier<T> callback) {
while (true) {
try {
return callback.get();
} catch (IllegalArgumentException e) {
println("[ERROR] %s", e.getMessage());
}
}
}
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.
감사합니다! 재귀 호출을 성능면에서 생각해보지 않은 것 같습니다! 달아주신 코드 참고하겠습니다 :)
20221130 자동차경주게임