Skip to content

Conversation

@SEUNGHEE96
Copy link

20221130 자동차경주게임

Copy link

@2jun0 2jun0 left a 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 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클래스의 명명 규칙은 변수와 달리 맨 앞 글자를 대문자로 해줘야 해요!

Copy link
Author

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();
Copy link

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());
        }
    }
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다! 재귀 호출을 성능면에서 생각해보지 않은 것 같습니다! 달아주신 코드 참고하겠습니다 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants