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

feat: 4단계 로또 수동 #2816

Merged
merged 2 commits into from
Nov 17, 2022
Merged

Conversation

AnneMayor
Copy link

@AnneMayor AnneMayor commented Nov 13, 2022

#2810 이슈를 해결하고자 작업하였습니다.

❗3단계 PR에서 남겨주신 코멘트도 반영하였습니다. 한번 확인 부탁드려요 🙇‍♀️

Copy link

@JunHoPark93 JunHoPark93 left a comment

Choose a reason for hiding this comment

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

안녕하세요 마지막 단계 구현하느라 고생하셨습니다.
코멘트 몇 가지 남겨두었는데 확인 후 의견 및 반영 부탁드려요!

Comment on lines 17 to 32
public static Rank findRank(int countOfMatchedNumber) {
switch (countOfMatchedNumber) {
case 6:
return Rank.FIRST;
case 5:
return Rank.SECOND;
case 7:
return Rank.SECOND_WITH_BONUS;
case 4:
return Rank.THIRD;
case 3:
return Rank.FOURTH;
default:
return Rank.UNKNOWN;
}
}

Choose a reason for hiding this comment

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

enum을 활용해주셨는데요, case문을 없앨수있도록 만들어보면 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

아 넵넵 한번 고민해보겠습니다 🙂


SIEVE.addAll(ticketNumbers);

if (SIEVE.size() != ticketNumbers.size()) throw new IllegalArgumentException("복권번호가 중복됩니다.");

Choose a reason for hiding this comment

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

한문장이라도 brace를 열면 어떨까요?

Comment on lines 9 to 10
private final List<LotteryNumber> ticketNumbers;
private final Set<LotteryNumber> SIEVE = new HashSet<>();

Choose a reason for hiding this comment

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

둘 다 유지될 필요가 있을까요? 불필요한 인스턴스 변수를 제거해보아요!
💡 규칙 8: 일급 콜렉션을 쓴다.


import java.util.Objects;

public class LotteryNumber {

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.

넵넵!알겠습니다~!

import java.util.Objects;

public class LotteryNumber {
private final int MIN_NUMBER = 1;

Choose a reason for hiding this comment

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

Suggested change
private final int MIN_NUMBER = 1;
private static final int MIN_NUMBER = 1;

Comment on lines 24 to 41
firstPrizeLotteryTicket = LotteryTicket.of(Arrays.asList(
LotteryNumber.of(1), LotteryNumber.of(2), LotteryNumber.of(3),
LotteryNumber.of(4), LotteryNumber.of(5), LotteryNumber.of(6)));
secondPrizeLotteryTicket = LotteryTicket.of(Arrays.asList(
LotteryNumber.of(1), LotteryNumber.of(2), LotteryNumber.of(3),
LotteryNumber.of(4), LotteryNumber.of(6), LotteryNumber.of(10)));
secondPrizeWithBonusLotteryTicket = LotteryTicket.of(Arrays.asList(
LotteryNumber.of(1), LotteryNumber.of(2), LotteryNumber.of(3),
LotteryNumber.of(4), LotteryNumber.of(6), LotteryNumber.of(11)));
noPrizeLotteryTicket = LotteryTicket.of(Arrays.asList(
LotteryNumber.of(11), LotteryNumber.of(12), LotteryNumber.of(13),
LotteryNumber.of(14), LotteryNumber.of(15), LotteryNumber.of(17)));
matchedWinnerLotteryTicket = new WinnerLotteryTicket(LotteryTicket.of(Arrays.asList(
LotteryNumber.of(1), LotteryNumber.of(2), LotteryNumber.of(3),
LotteryNumber.of(4), LotteryNumber.of(5), LotteryNumber.of(6))), LotteryNumber.of(11));
unmatchedWinnerLotteryTicket = new WinnerLotteryTicket(LotteryTicket.of(Arrays.asList(
LotteryNumber.of(1), LotteryNumber.of(2), LotteryNumber.of(3),
LotteryNumber.of(4), LotteryNumber.of(5), LotteryNumber.of(6))), LotteryNumber.of(7));

Choose a reason for hiding this comment

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

fixture 중복을 줄여보면 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

아 넵넵 한번 고민해보겠습니다 😊

Copy link

@JunHoPark93 JunHoPark93 left a comment

Choose a reason for hiding this comment

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

안녕하세요 로또 마지막 step 리뷰 반영하시느라 고생많으셨습니다.
그래도 초반 step들보다 domain들이 더 풍성해진거같아서 좋네요.
앞으로 다른미션이나 업무에 있어서 도움이 되기를 바랍니다 🙏
고생많으셨어요.

this.reward = reward;
}

public static Rank findRank(int countOfMatchedNumber) {

Choose a reason for hiding this comment

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

case문이 제거가 됐네요 훨씬 구조가 나아진거같습니다.

Comment on lines +8 to +10
private final List<LotteryNumber> ticketNumbers;

public LotteryTicket(List<Integer> ticketNumbers) {
private static final int COUNT_OF_LOTTERY_NUMBERS = 6;

Choose a reason for hiding this comment

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

불필요한 변수를 잘 제거해주셨습니다!
다만 8,10라인 선언 위치만 변경부탁드려요 :)

Comment on lines +73 to +75
LotteryTicket secondPrizeLotteryTicket = LotteryTicket.of(Arrays.asList(
LotteryNumber.of(1), LotteryNumber.of(2), LotteryNumber.of(3),
LotteryNumber.of(4), LotteryNumber.of(6), LotteryNumber.of(10)));

Choose a reason for hiding this comment

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

더 나아가면 숫자만 전달하면 LotteryTicket이 나오는 fixture메서드를 만들 수도 있겠네요!

@JunHoPark93 JunHoPark93 merged commit 298ad08 into next-step:annemayor Nov 17, 2022
@AnneMayor AnneMayor deleted the step4 branch November 22, 2022 20:54
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