-
Notifications
You must be signed in to change notification settings - Fork 1.1k
로또: 4단계 - 로또(수동) #4173
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
Open
mia-developer
wants to merge
1
commit into
next-step:mia-developer
Choose a base branch
from
mia-developer:lotto/step4
base: mia-developer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
로또: 4단계 - 로또(수동) #4173
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/lotto/domain/model/lotto/TotalTicketCount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package lotto.domain.model.lotto; | ||
|
||
public class TotalTicketCount { | ||
|
||
private final TicketCount totalTicketCount; | ||
private final TicketCount autoTicketCount; | ||
private final TicketCount manualTicketCount; | ||
|
||
public TotalTicketCount(final TicketCount totalTicketCount, final TicketCount manualTicketCount) { | ||
validate(totalTicketCount, manualTicketCount); | ||
this.totalTicketCount = totalTicketCount; | ||
this.manualTicketCount = manualTicketCount; | ||
this.autoTicketCount = totalTicketCount.substract(manualTicketCount.getCount()); | ||
} | ||
|
||
private void validate(final TicketCount totalTicketCount, final TicketCount manualTicketCount) { | ||
if (totalTicketCount.getCount() < manualTicketCount.getCount()) { | ||
throw new IllegalArgumentException("수동으로 구매하려는 로또 수가 총 구매 가능한 로또 수를 초과합니다."); | ||
} | ||
} | ||
|
||
public TicketCount getTotalTicketCount() { | ||
return totalTicketCount; | ||
} | ||
|
||
public TicketCount getAutoTicketCount() { | ||
return autoTicketCount; | ||
} | ||
|
||
public TicketCount getManualTicketCount() { | ||
return manualTicketCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package lotto.view; | ||
|
||
import lotto.domain.model.lotto.PurchaseAmount; | ||
import lotto.domain.model.lotto.BonusNumber; | ||
import lotto.domain.model.lotto.LottoNumber; | ||
import lotto.domain.model.lotto.*; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
@@ -16,13 +14,34 @@ public PurchaseAmount inputPurchaseAmount() { | |
return new PurchaseAmount(Integer.parseInt(scanner.nextLine())); | ||
} | ||
|
||
public TicketCount inputManualTicketCount() { | ||
System.out.println("수동으로 구매할 로또 수를 입력해 주세요."); | ||
return new TicketCount(Integer.parseInt(scanner.nextLine())); | ||
} | ||
|
||
public List<LottoTicket> inputManualTicketNumbers(final TicketCount manualTicketCount) { | ||
Comment on lines
+17
to
+22
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. 한번 디자인 패턴중 전략패턴을 고민해보셨으면 좋겠습니다. |
||
System.out.println("수동으로 구매할 번호를 입력해 주세요."); | ||
List<LottoTicket> tickets = new ArrayList<>(); | ||
|
||
for (int i = 0; i < manualTicketCount.getCount(); i++) { | ||
tickets.add(new LottoTicket(inputLottoNumbers())); | ||
} | ||
Comment on lines
+25
to
+28
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. 실제 도메인을 View단에서 만드는게 맞을까요? |
||
|
||
return tickets; | ||
} | ||
|
||
public BonusNumber inputBonusNumber() { | ||
System.out.println("보너스 볼을 입력해 주세요."); | ||
return new BonusNumber(Integer.parseInt(scanner.nextLine())); | ||
} | ||
|
||
public Set<LottoNumber> inputWinningNumbers() { | ||
System.out.println("지난 주 당첨 번호를 입력해 주세요. (쉼표로 구분)"); | ||
System.out.println("지난 주 당첨 번호를 입력해 주세요."); | ||
|
||
return inputLottoNumbers(); | ||
} | ||
|
||
private Set<LottoNumber> inputLottoNumbers() { | ||
String[] tokens = scanner.nextLine().split(","); | ||
|
||
return Stream.of(tokens) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 validate의 의미가 조금 이상하네요.
로직이 틀렸다기 보단, 실제 "autoTicketCount"에 대해서도 필요하지 않을까 생각이 듭니다.