Open
Conversation
hoyeonyy
reviewed
May 6, 2024
|
|
||
| private int findStrike(List<Integer> input) { | ||
| return (int) IntStream.range(0, 3) | ||
| .filter(i -> answer.get(i).equals(input.get(i))) |
hoyeonyy
reviewed
May 6, 2024
|
|
||
| private int findBall(List<Integer> input) { | ||
| return (int) IntStream.range(0, 3) | ||
| .filter(i -> !answer.get(i).equals(input.get(i)) && answer.contains(input.get(i))) |
hoyeonyy
reviewed
May 6, 2024
| public static List<Integer> generate(){ | ||
| List<Integer> threeDigitNumber = new ArrayList<>(); | ||
| while (threeDigitNumber.size() < 3) { | ||
| int randomNumber = Randoms.pickNumberInRange(startRange, endRange); |
hoyeonyy
reviewed
May 6, 2024
hoyeonyy
reviewed
May 6, 2024
Comment on lines
+8
to
+35
| @Test | ||
| @DisplayName("입력과 정답을 받아 스트라이크 볼의 개수를 가진다.") | ||
| void generate() { | ||
| int strike = 1; | ||
| int ball = 1; | ||
|
|
||
| Assertions.assertDoesNotThrow(() -> | ||
| new ComparisonResult(strike, ball)); | ||
|
|
||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("3스트라이크일 때 true를 반환한다.") | ||
| void ThreeStrikeTrue() { | ||
| int strike = 3; | ||
| int ball = 0; | ||
| ComparisonResult result = new ComparisonResult(strike, ball); | ||
| Assertions.assertEquals(result.isThreeStrike(), true); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("3스트라이크가 아니면 false를 반환한다.") | ||
| void ThreeStrikeFalse() { | ||
| int strike = 2; | ||
| int ball = 1; | ||
| ComparisonResult result = new ComparisonResult(strike, ball); | ||
| Assertions.assertEquals(result.isThreeStrike(), false); | ||
| } |
hoyeonyy
reviewed
May 6, 2024
| List<Integer> threeDigitNumber = new ArrayList<>(); | ||
| while (threeDigitNumber.size() < 3) { | ||
| int randomNumber = Randoms.pickNumberInRange(startRange, endRange); | ||
| if (!threeDigitNumber.contains(randomNumber)) { |
hoyeonyy
reviewed
May 6, 2024
| } | ||
|
|
||
| private void isNotThreeDigitNumber(String input) { | ||
| if (!Pattern.matches(threeDigitPattern, input)) { |
hoyeonyy
reviewed
May 6, 2024
| void compare2Ball1Strike() throws Exception { | ||
| List<Integer> input = List.of(1, 3, 2); | ||
|
|
||
| ComparisonResult result = computer.compare(input); |
hoyeonyy
reviewed
May 6, 2024
|
|
||
| public class InputNumberGenerator { | ||
|
|
||
| public static List<Integer> generate(String input) { |
hoyeonyy
reviewed
May 6, 2024
|
|
||
| @Override | ||
| public String toString() { | ||
| StringBuilder stringBuilder = new StringBuilder(); |
hoyeonyy
reviewed
May 6, 2024
|
|
||
| public record ComparisonResult(int strike, int ball) { | ||
|
|
||
| public Boolean isThreeStrike() { |
hoyeonyy
reviewed
May 6, 2024
|
|
||
| public static List<Integer> generate(){ | ||
| List<Integer> threeDigitNumber = new ArrayList<>(); | ||
| while (threeDigitNumber.size() < 3) { |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.