Skip to content

lotto - step3 #4172

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

Merged
merged 6 commits into from
Apr 8, 2025
Merged

lotto - step3 #4172

merged 6 commits into from
Apr 8, 2025

Conversation

gimsesu
Copy link

@gimsesu gimsesu commented Apr 7, 2025

감사합니다.

Copy link

@jinyoungchoi95 jinyoungchoi95 left a comment

Choose a reason for hiding this comment

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

안녕하세요 성수님 😄

미션 잘 진행해주셨네요! 몇가지 코멘트 남겨두었으니 다음 미션 진행하시면 함께 확인부탁드려요 :)

궁금하거나 고민이 되는 부분이 있으시다면 언제든 pr 코멘트 또는 dm으로 요청 부탁드립니다.
감사합니다 🙇‍♂️


import java.util.Objects;

public class LottoNumber {

Choose a reason for hiding this comment

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

value object 👍

import java.util.Arrays;
import java.util.List;

public enum Rank {

Choose a reason for hiding this comment

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

잘 옮겨주셨네요 👍

THIRD(Arrays.asList(5), 1_500_000, false),
FOURTH(Arrays.asList(4), 50_000, false),
FIFTH(Arrays.asList(3), 5_000, false),
MISS(Arrays.asList(0, 1, 2), 0, false);

Choose a reason for hiding this comment

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

👍

Comment on lines +41 to +53
if (countOfMatch > 6) {
throw new IllegalArgumentException("일치하는 번호는 최대 6개까지만 가능합니다.");
}

if (countOfMatch == 5) {
return matchBonus ? SECOND : THIRD;
}

return Arrays.stream(values())
.filter(rank -> rank.matchCounts.contains(countOfMatch))
.findFirst()
.orElse(MISS);
}

Choose a reason for hiding this comment

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

stream 한번으로 모두 처리할 수 있어보여요!

  1. matchCounts가 포함되는 경우 필터링
  2. bonus가 일치하는 경우 필터링
  3. 모두 아니면 예외처리

if (numbers.size() != LOTTO_SIZE) {
throw new IllegalArgumentException("로또 번호는 6개여야 합니다.");
}
public static Lotto of(List<Integer> numbers) {

Choose a reason for hiding this comment

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

정적 팩토리 메서드의 경우 관습적으로 파라메터가 1개인 경우 from을 사용합니다. 파라메터가 여러개일 때 of를 사용하여요.

영문표현과 연관있는 관습이라고 봐주시면 좋을 것 같네요 😄

@jinyoungchoi95 jinyoungchoi95 merged commit a4e451c into next-step:gimsesu Apr 8, 2025
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