-
Notifications
You must be signed in to change notification settings - Fork 34
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
[포키 && 필] 로또 3단계 - 수동구매 기능 추가 #55
Open
PhilSoGooood
wants to merge
7
commits into
codesquad-members-2022:PhilSoGooood
Choose a base branch
from
PhilSoGooood:step3
base: PhilSoGooood
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.
+784
−139
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
efac5bc
.gitignore 추가
PhilSoGooood b6a7571
리팩토링: LottoGame내의 기능을 분리하였습니다.
PhilSoGooood 6d1befc
리팩토링: LottoService로부터 LottoTickets를 분리하였습니다.
PhilSoGooood 69b3087
리팩토링: Scanner의 close 추가 및 OutputView의 메서드 매개변수
PhilSoGooood 5add77b
gradle 파일추가
PhilSoGooood b9ae9bc
기능 구현: 수동 번호 입력 기능 구현하였습니다.
PhilSoGooood ea47d09
기능구현: 예외를 처리하는 기능을 구현하였습니다.
PhilSoGooood 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
Prev
Previous commit
기능구현: 예외를 처리하는 기능을 구현하였습니다.
구매금액과 수동 구매 수량, 당첨번호, 보너스 번호 입력에 대해 예외처리를 하도록 했습니다.
commit ea47d09df9b8be226d532cb648a89cbf1f110716
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.lotto.util; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
public class ValidationUtil { | ||
private static final String NUMBER_PATTERN = "([1-9]|1[0-9]|2[0-9]|3[0-9]|4[0-5])((, )([1-9]|1[0-9]|2[0-9]|3[0-9]|4[0-5])){5}"; | ||
|
||
public static void validateManualCountRange(int count, int purchaseAmount) { | ||
if (count > purchaseAmount / 1000 || count < 0) { | ||
throw new IllegalArgumentException("숫자를 확인해주세요."); | ||
} | ||
} | ||
|
||
public static String[] validateTicketFormat(String ticketNumbers) { | ||
|
||
if (!Pattern.matches(NUMBER_PATTERN, ticketNumbers)) { | ||
throw new IllegalArgumentException("형식이 올바르지 않습니다"); | ||
} | ||
return ticketNumbers.replaceAll(" ", "").split(","); | ||
} | ||
|
||
public static void checkDuplicate(String[] ticketNumbers) { | ||
Set<String> result = new HashSet<>(); | ||
for (String ticketNumber : ticketNumbers) { | ||
result.add(ticketNumber); | ||
} | ||
if (result.size() != 6) { | ||
throw new IllegalArgumentException("숫자가 중복되지 없도록 입력해주세요."); | ||
} | ||
} | ||
|
||
public static void validateBonusNumber(int bonusNumber, List<Integer> winningNumbers) { | ||
if (bonusNumber > 46 || bonusNumber < 1) { | ||
throw new IllegalArgumentException("1 ~ 45 사이의 숫자를 입력해주세요."); | ||
} | ||
if (winningNumbers.contains(bonusNumber)) { | ||
throw new IllegalArgumentException("당첨번호와 중복되지 않는 번호로 입력해주세요."); | ||
} | ||
} | ||
} |
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.
List<Integer>
는 여기에서 어떤 의미를 갖나요? 로또 번호에 대한 사용자 입력, 혹은 로또번호의 집합 그 자체가 될 수 있을 것 같은데요...이걸 적절히 감싸서 리스트를 원소로 갖는 리스트, 즉
List<List<Integer>>
를 쓰지 않도록 리팩터링 부탁드려요.