-
Notifications
You must be signed in to change notification settings - Fork 248
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
[디디] 로또 미션 제출합니다. #129
Merged
Merged
[디디] 로또 미션 제출합니다. #129
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f37d3bd
feat: 구입 금액 검증(단위, 문자열)
KIMSIYOUNG 247bc02
feat : 로또 한장을 의미하는 Number 객체 검증
KIMSIYOUNG b20a623
feat : Lotto 한장을 담당하는 객체 검증
KIMSIYOUNG 9c2a4fc
feat : LottoFactory 및 Lottos 구현 및 검증
KIMSIYOUNG 05a397d
feat : 보너스번호와 당첨번호를 관리하기 위한 객체 추가
KIMSIYOUNG aa5dec7
feat : 당첨 통계를 위한 클래스 추가
KIMSIYOUNG 7d0c36f
docs : WinningNumber와 BonusNumber 관련 할 일 추가
KIMSIYOUNG b333217
feat : 보너스넘버가 당첨번호와 중첩되지 않도록 개발
KIMSIYOUNG a005aa7
refactor : equals를 사용해서 객체간의 비교
KIMSIYOUNG 3293674
copy branch
KIMSIYOUNG 7956a4d
refactor : BonusNumber 클래스 삭제 및 리팩토링
KIMSIYOUNG 0331441
refactor : WinningNumbers 클래스 삭제 및 리팩토링
KIMSIYOUNG d066ab3
refactor : 객체의 역할에 맞게 기능 재 분배
KIMSIYOUNG 3fdfbb6
refactor : 리팩토링한 클래스 및 테스트 추가
KIMSIYOUNG 74b1a24
임시커밋
fucct f26c9ed
refactor : 피드백 반영
fucct 42afa81
refactor: 컨벤션 맞춤
fucct 8e7375e
refactor: 피드백 반영
fucct 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
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,7 +1,6 @@ | ||
package lotto.domain.result; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Stream; | ||
|
||
public enum Rank { | ||
DEFAULT(0, 0, false), | ||
|
@@ -11,7 +10,6 @@ public enum Rank { | |
BONUS(5, 30_000_000, true), | ||
SIX(6, 2_000_000_000, false); | ||
|
||
public static final int FIVE_MATCH = 5; | ||
private final int matchingNumbers; | ||
private final int prize; | ||
private final boolean bonusMatching; | ||
|
@@ -23,16 +21,9 @@ public enum Rank { | |
} | ||
|
||
public static Rank getRank(int numberOfMatch, boolean isBonus) { | ||
Stream<Rank> rankStream = Arrays.stream(values()) | ||
.filter(statistic -> statistic.matchingNumbers == numberOfMatch); | ||
|
||
if (numberOfMatch != FIVE_MATCH) { | ||
return rankStream | ||
.findFirst() | ||
.orElse(DEFAULT); | ||
} | ||
return rankStream | ||
.filter(statistic -> statistic.bonusMatching == isBonus) | ||
return Arrays.stream(values()) | ||
.filter(rank -> rank.matchingNumbers == numberOfMatch) | ||
.filter(rank->rank.checkBonus(isBonus)) | ||
.findFirst() | ||
.orElse(DEFAULT); | ||
} | ||
|
@@ -49,7 +40,17 @@ public boolean isNotDefault() { | |
return matchingNumbers != 0; | ||
} | ||
|
||
public boolean isBonusMatching() { | ||
return matchingNumbers == FIVE_MATCH && bonusMatching; | ||
public boolean checkBonus(boolean isBonus) { | ||
if (this == BONUS || this == FIVE) { | ||
return bonusMatching == isBonus; | ||
} | ||
return true; | ||
} | ||
|
||
public boolean isBonus(){ | ||
if(this==BONUS){ | ||
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. 띄어쓰기 컨벤션 위반입니다. 그리고 if분기문을 축약해 쓸 수 있겠네요~ |
||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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.
띄어쓰기 컨벤션 위반입니다.