-
Notifications
You must be signed in to change notification settings - Fork 2
미션4_로또 게임 수동 #12
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
base: psh
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uBBF8\uC158_4-\uB85C\uB610\uAC8C\uC784_\uC218\uB3D9"
미션4_로또 게임 수동 #12
Changes from 16 commits
b4287d6
d6529c2
02dde32
e25d0e0
9dc4cce
f0e2d5c
2338e36
5dbd0e7
c6429fb
6576481
e94b114
2a6e1b6
e3c822c
ab04122
0471dfb
442c41c
d3d0aba
167e34a
37aa7fb
51a569e
eb6d329
a913957
6d38f29
032c611
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,76 @@ | ||
| package lotto.domain; | ||
|
|
||
| import static lotto.domain.LottoTicket.LOTTO_PRICE; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import static lotto.domain.LottoTicket.LOTTO_PRICE; | ||
|
|
||
| public class LottoConsumer { | ||
|
|
||
| /** 구매한 로또 티켓 목록 */ | ||
| private final List<LottoTicket> lottoTickets = new ArrayList<>(); | ||
| private final List<LottoTicket> lottoTickets; | ||
|
|
||
| /** 수동 로또 구매 개수 */ | ||
| private final int manualLottoCount; | ||
|
|
||
| public LottoConsumer(int manualLottoCount) { | ||
| this.lottoTickets = new ArrayList<>(); | ||
| this.manualLottoCount = manualLottoCount; | ||
| } | ||
|
|
||
| /** | ||
| * 로또 번호 생성하고 반환 합니다. | ||
| * 자동 로또 티켓을 구매합니다. | ||
| * | ||
| * @param money 구매할 금액 | ||
| * */ | ||
| */ | ||
| public void buyLotto(int money) { | ||
| LottoGenerator generator = new LottoGenerator(); | ||
|
|
||
| int purchasedCount = money / LOTTO_PRICE; | ||
| int autoPurchasedCount = purchasedCount - manualLottoCount; | ||
|
|
||
| for (int i = 0; i < purchasedCount; i++) { | ||
| LottoGenerator generator = new LottoGenerator(); | ||
| lottoTickets.add(new LottoTicket(generator.generate())); | ||
| for (int i = 0 ; i < autoPurchasedCount ; i++) { | ||
| lottoTickets.add(generator.autoGenerate()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 수동 로또 티켓을 구매합니다. | ||
| * | ||
| * @param lottoNumbers 수동 로또 티켓 목록 | ||
| */ | ||
| public void buyManualLotto(List<String[]> lottoNumbers) { | ||
| LottoGenerator generator = new LottoGenerator(); | ||
babysean marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| for (String[] lottoNumber : lottoNumbers) { | ||
| lottoTickets.add(generator.manualGenerate(lottoNumber)); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 구매한 로또 티켓 목록을 반환 합니다. | ||
| * | ||
| * @return List<LottoTicket> | ||
| * */ | ||
| */ | ||
| public List<LottoTicket> getLottoTickets() { | ||
| return lottoTickets; | ||
| } | ||
|
|
||
| /** | ||
| * 자동 로또 티켓 개수를 반환합니다. | ||
| * | ||
| * @return int | ||
| */ | ||
| public int getAutoLottoTicketCount() { | ||
| return lottoTickets.size() - manualLottoCount; | ||
babysean marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * 수동 로또 티켓 개수를 반환합니다. | ||
| * | ||
| * @return int | ||
| */ | ||
| public int getManualLottoTicketCount() { | ||
| return manualLottoCount; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,10 +35,11 @@ public boolean getIsWonBonusNumber() { | |
| /** | ||
| * matches 와 bonus 에 맞는 값을 반환 합니다. | ||
| * | ||
| * @param matches 맞춘 개수 | ||
| * @param matches 맞춘 개수 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅋㅋ 줄 맞 춤 하셨군요
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이거 컨벤션 적용한건데 javadocs의 default가 저건 가봐요 ㅎㅎ
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 별뜻은 없었습니다~! 갑자기 줄을 맞추셔서 리액션.. |
||
| * @param isWonBonusNumber 보너스 번호 맞춘 여부 | ||
| * | ||
| * @return LottoPrize | ||
| * */ | ||
| */ | ||
| public static LottoPrize findByMatchesAndBonus(int matches, boolean isWonBonusNumber) { | ||
| return Arrays.stream(values()) | ||
| .filter(prize -> isMatched(prize, matches, isWonBonusNumber)) | ||
|
|
@@ -49,11 +50,12 @@ public static LottoPrize findByMatchesAndBonus(int matches, boolean isWonBonusNu | |
| /** | ||
| * 로또 티켓을 확인 합니다. | ||
| * | ||
| * @param prize 로또 티켓의 결과 | ||
| * @param checkedCount 확인할 맞춘 개수 | ||
| * @param prize 로또 티켓의 결과 | ||
| * @param checkedCount 확인할 맞춘 개수 | ||
| * @param isWonBonusNumber 보너스 번호 맞춘 여부 | ||
| * | ||
| * @return boolean | ||
| * */ | ||
| */ | ||
| public static boolean isMatched(LottoPrize prize, int checkedCount, boolean isWonBonusNumber) { | ||
| if (checkedCount == SECOND_MATCHED_COUNT) { | ||
| return checkSecond(prize, checkedCount, isWonBonusNumber); | ||
|
|
@@ -65,11 +67,12 @@ public static boolean isMatched(LottoPrize prize, int checkedCount, boolean isWo | |
| /** | ||
| * 로또 티켓의 2등을 확인합니다. | ||
| * | ||
| * @param prize 로또 티켓의 결과 | ||
| * @param checkedCount 확인할 맞춘 개수 | ||
| * @param prize 로또 티켓의 결과 | ||
| * @param checkedCount 확인할 맞춘 개수 | ||
| * @param isMatchedBonusNumber 보너스 번호 맞춘 여부 | ||
| * | ||
| * @return boolean | ||
| * */ | ||
| */ | ||
| private static boolean checkSecond(LottoPrize prize, int checkedCount, boolean isMatchedBonusNumber) { | ||
| if (isMatchedBonusNumber) { | ||
| return prize.getIsWonBonusNumber() && prize.getMatches() == checkedCount; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.