Open
Conversation
Author
|
간단한 테스트 로직을 추가했습니다! |
GoToBILL
reviewed
May 7, 2024
GoToBILL
reviewed
May 7, 2024
| Set<Integer> nonDuplicateNumbers = new HashSet<>(numbersList); | ||
| return nonDuplicateNumbers.size(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Set<Integer> seen = new HashSet<>();
if (lottoNumbers.stream()
.anyMatch(n -> !seen.add(n.getNumber()))) throw new IllegalArgumentException("로또는 중복돼서는 안됩니다.");
스트림 문법을 쓰시면 더 깔끔하게 하실 수 있어요!
Author
There was a problem hiding this comment.
private void validateDuplication(List<LottoNumber> numbers) {
Set<Integer> seenNumbers = new HashSet<>();
if (numbers.stream()
.anyMatch(n -> !seenNumbers.add(n.getLottoNumber()))) throw new IllegalArgumentException("로또는 중복돼서는 안됩니다.");
}
감사합니다 👍
GoToBILL
reviewed
May 7, 2024
| } | ||
| return false; | ||
| } | ||
| } |
Author
There was a problem hiding this comment.
public boolean iscontained(int number) {
return lotto.stream()
.map(LottoNumber::getLottoNumber)
.collect(Collectors.toList())
.contains(number);
}
``` 훨씬 깔끔하네용👍
GoToBILL
reviewed
May 7, 2024
| throw new IllegalArgumentException("로또 숫자는 숫자형식이어야 합니다."); | ||
| } | ||
| } | ||
| } |
GoToBILL
reviewed
May 7, 2024
| lottos.add(lotto); | ||
| } | ||
|
|
||
| } |
GoToBILL
reviewed
May 7, 2024
| public int ticket() { | ||
| return money / 1000; | ||
| } | ||
| } |
GoToBILL
reviewed
May 7, 2024
| public static void printPercent(double profitPercent) { | ||
| System.out.println("총 수익률은 " + profitPercent + "%입니다."); | ||
| } | ||
| } |
GoToBILL
reviewed
May 7, 2024
| } | ||
|
|
||
| Collections.shuffle(numbers); | ||
|
|
GoToBILL
reviewed
May 7, 2024
| compareUserLotto(lastWeekLotto,lotto); | ||
| checkBonusNum(lastWeekLotto, bonusNum); | ||
|
|
||
| checkBingoList(correctNum, bonusFlag); |
GoToBILL
reviewed
May 7, 2024
| public void findBingo6(int correctNum) { | ||
| if (correctNum == 6) Bingo.getBingo6().addCorrectLottoNum(); | ||
| } | ||
| } |
There was a problem hiding this comment.
따로 클래스를 파셔서 하셨는데 ENUM에서 내부 매소드를 이용해서 enum의 정보를 이용하는 방법도 있어요.
예시로 ordinal이라는 함수를 이용하면 몇번째로 구현됐는 지도 알려줘서 따로 리스트를 만들어서 index로 저장하는 방법도 있습니다.
GoToBILL
reviewed
May 7, 2024
| return bingo6; | ||
| } | ||
|
|
||
| } |
GoToBILL
reviewed
May 7, 2024
| public static void showProfit(int money) { | ||
| OutputView.printPercent(calculate(money)); | ||
| } | ||
| } |
There was a problem hiding this comment.
다 좋은데 controller가 너무 비대한 것 같아요.
몇몇을 분리해 줄 필요가 있을 것 같아요
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.
처음에는 Lotto안의 숫자들을 int값으로 설정하여 하였다가
Lotto안의 숫자들을 LottoNumber로 한번 더 감싸서 만들어보았습니다.
이 과정에서 기초적인 자바문법으로는 한계가 있다는 것을 느꼈고,
고급 자바문법(stream,forEach..)의 필요성을느꼈습니다.
예외처리까지는 했는데, 시간이 부족해 테스트 로직을 짜지 못했습니다.
부족한점이 많지만 리뷰 부탁드립니다!🙇♂️
같이 생각해보고 싶은점