-
Notifications
You must be signed in to change notification settings - Fork 1.1k
피드백적용 및 로또 2단계 구현 #139
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
Merged
Merged
피드백적용 및 로또 2단계 구현 #139
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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,28 +1,13 @@ | ||
package domain; | ||
|
||
import java.util.List; | ||
|
||
public class Lotto { | ||
private Numbers numbers; | ||
private LottoNumbers lottoNumbers; | ||
|
||
public static Lotto generateLotto(List<Integer> integers) { | ||
Lotto lotto = new Lotto(); | ||
lotto.numbers = new Numbers(integers); | ||
return lotto; | ||
public Lotto (LottoNumbers numbers) { | ||
this.lottoNumbers = numbers; | ||
} | ||
|
||
public LottoResultStatus getLottoResultStatus(int[] winningNumbers) { | ||
int containsWinningNumberCount = 0; | ||
for (int number : winningNumbers) { | ||
if(numbers.contains(number)) | ||
containsWinningNumberCount ++; | ||
} | ||
|
||
return LottoResultStatus.findByMatchCount(containsWinningNumberCount); | ||
public LottoNumbers getLottoNumbers() { | ||
return this.lottoNumbers; | ||
} | ||
|
||
public Numbers getNumbers() { | ||
return this.numbers; | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,38 @@ | ||
package domain; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class LottoNumbers { | ||
public static final int LOTTO_NUMBER_SIZE = 6; | ||
private List<Number> numbers; | ||
|
||
private LottoNumbers(List<Integer> inputNumbers) { | ||
List<Number> list = inputNumbers.stream().map(Number::createInstance).collect(Collectors.toList()); | ||
this.numbers = list; | ||
} | ||
|
||
public static LottoNumbers createInstance(List<Integer> inputNumbers) { | ||
if (inputNumbers.size() != LOTTO_NUMBER_SIZE) { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
return new LottoNumbers(inputNumbers); | ||
} | ||
|
||
public boolean contains(Number number) { | ||
return numbers.stream().map(num -> num.equals(number)).anyMatch(num -> num.equals(true)); | ||
} | ||
|
||
public String toString() { | ||
StringBuffer resultString = new StringBuffer(); | ||
resultString.append("["); | ||
numbers.forEach(number -> resultString.append(number.toString()+" ")); | ||
resultString.append("]"); | ||
return resultString.toString(); | ||
} | ||
|
||
public List<Number> getNumbers() { | ||
return numbers; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 domain; | ||
|
||
import java.util.Objects; | ||
|
||
public class Number { | ||
private static final int MININUM_NUMBER = 1; | ||
private static final int MAXIMUM_NUMBER = 46; | ||
private Integer number; | ||
|
||
private Number(Integer number) { | ||
if (number < MININUM_NUMBER || number > MAXIMUM_NUMBER) { | ||
throw new IllegalArgumentException(); | ||
} | ||
this.number = number; | ||
} | ||
|
||
public static Number createInstance(Integer integerNumber) { | ||
return new Number(integerNumber); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Integer.toString(number); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof Number)) return false; | ||
Number number1 = (Number) o; | ||
return Objects.equals(number, number1.number); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.