Skip to content
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

[java-lotto] yohan.kim(김요한) 과제 제출합니다. #2

Open
wants to merge 25 commits into
base: yohan/java-lotto
Choose a base branch
from

Conversation

yohanii
Copy link
Member

@yohanii yohanii commented Oct 1, 2024

[java-lotto] yohan.kim(김요한) 과제 제출합니다.

@yohanii yohanii changed the base branch from main to yohan/java-lotto October 1, 2024 02:50
Copy link

@alreadysons alreadysons left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!! 리뷰 확인 부탁드리겠습니다!

@@ -11,10 +14,59 @@ public Lotto(List<Integer> numbers) {
}

private void validate(List<Integer> numbers) {

Choose a reason for hiding this comment

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

Lotto 내부에서 예외처리를 선언하다보니 코드가 지저분해지는것 같습니다! 클래스를 따로 만들어 예외처리를 하는 방법은 별로인가요??

assertThatThrownBy(() -> new Lotto(List.of(1, 2, 3, 4, 5, 5)))
.isInstanceOf(IllegalArgumentException.class);
}

// 아래에 추가 테스트 작성 가능
@DisplayName("6개 일치하면, 1을 반환한다.")

Choose a reason for hiding this comment

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

테스트를 직접 만드신 부분 대단합니다 👍

Comment on lines +15 to +27
int purchaseCount = seller.calculateLottoCount(seller.parsePurchaseMoneyStr(purchaseMoneyStr));

List<Lotto> lottos = seller.getLottos(purchaseCount);
UI.printBoughtLottos(lottos);

List<Integer> answers = UI.receiveAnswers();
int bonus = UI.receiveBonus();

List<Integer> result = seller.getResult(lottos, answers, bonus);
UI.printResult(result);
UI.printRate(seller.calculateRate(result, purchaseCount));
} catch (IllegalArgumentException e) {
UI.handlingIllegalArgumentException(e);
Copy link

Choose a reason for hiding this comment

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

MVC 패턴에 따라 설게구조를 변경해도 좋을 듯 합니다! 이 부분을 컨트롤러로 분리해도 좋을 것 같아요!

Comment on lines +49 to +66
private static int getBonusCorrect(int bonus, Set<Integer> set, int correct) {
if (set.contains(bonus) && correct == 5) {
return 1;
}
return 0;
}

// TODO: 추가 기능 구현
private int rankByCondition(int correct, int bonusCorrect) {
if (correct == 6) {
return 1;
}

if (correct + bonusCorrect <= 2) {
return 6;
}

return 8 - (correct + bonusCorrect);
}
Copy link

Choose a reason for hiding this comment

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

아까 피드백 드렸듯이, 매직 넘버를 상수로 치환하는 것이 좋습니다. 더 의미있는 상수로 치환해주세요!

Comment on lines +69 to 72
public String toString() {
return numbers.toString();
}
}
Copy link

Choose a reason for hiding this comment

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

객체를 더 객체답게 사용하려면 toString() 더 의미있는 내용을 리턴할 수 있도록 할 수 있을 것 같아요. 단순히 getter 와 비슷하게 데이터를 리턴하는게 아니라, 객체의 상태를 표현할 수 있는 더 의미있는 정보를 리턴해도 좋을 것 같습니다!

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.

3 participants