Conversation
jiseop121
reviewed
Mar 21, 2024
jiseop121
left a comment
There was a problem hiding this comment.
메서드분리와 상수클래스 분리, 테스트 작성을 하는 것을 중점으로 리팩토링하시면 될 것 같습니다.
| import lotto.domain.Lotto; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
There was a problem hiding this comment.
validation 클래스를 검증하는 용도로 test코드를 작성해주시면 더 좋을 것 같습니다.
Comment on lines
+11
to
+15
| private static final String PURCHASED_COUNT_MESSAGE = "\n%d개를 구매했습니다.\n"; | ||
| private static final String WINNING_STATICS_MESSAGE = "\n당첨 통계\n---"; | ||
| private static final String WINNING_DETAIL_MESSAGE = "%d개 일치 (%s원) - %d개\n"; | ||
| private static final String WINNING_BONUS_DETAIL_MESSAGE = "%d개 일치, 보너스 볼 일치 (%s원) - %d개\n"; | ||
| private static final String RETURN_RATE_MESSAGE = "총 수익률은 %.1f%%입니다."; |
Comment on lines
+24
to
+31
| private void generatedLotto() { | ||
| for (int i=0; i<lottoCount; i++) { | ||
| List<Integer> numbers = new ArrayList<>( | ||
| Randoms.pickUniqueNumbersInRange(1, 45, 6)); | ||
| Collections.sort(numbers); | ||
| lottoSet.add(new Lotto(numbers)); | ||
| } | ||
| } |
Comment on lines
+53
to
+58
| for (Lotto lotto : lottoSet) { | ||
| int match = compareNumbers(lotto.getNumbers(), winningLotto.getWinningNumber()); | ||
| boolean containBonus = isContainBonus(lotto.getNumbers(), winningLotto.getBonusNumber(), match); | ||
| WinningRank winningRank = WinningRank.findWinningRank(match, containBonus); | ||
| winningResult.replace(winningRank, winningResult.get(winningRank) + 1); | ||
| } |
There was a problem hiding this comment.
이 부분도 계산하는 역할의 클래스를 분리하거나 메서드 분리가 좋아보입니다.
Cassiiopeia
reviewed
Mar 26, 2024
Member
Cassiiopeia
left a comment
There was a problem hiding this comment.
잘봤습니다~ 제 코드 보고 반성하게되네요 ㅜㅜ
Comment on lines
+8
to
+14
| private static final String INPUT_LOTTO_PRICE_ERROR = "[ERROR] 구입 금액은 1,000원 단위로 입력해주세요."; | ||
| private static final String INPUT_TYPE_ERROR = "[ERROR] 숫자를 입력해주세요."; | ||
| private static final String INPUT_NUMBER_RANGE_ERROR = "[ERROR] 로또 번호는 1부터 45 사이의 숫자여야 합니다."; | ||
| private static final String INPUT_LOTTO_SIZE_ERROR = "[ERROR] 당첨 번호는 서로 다른 6개의 수로 입력해주세요."; | ||
| private static final String LOTTO_NUMBER_DUPLICATED_ERROR = "[ERROR] 당첨 번호 중 중복되는 번호가 있습니다."; | ||
| private static final String INPUT_BONUS_RANGE_ERROR = "[ERROR] 보너스 번호는 1부터 45 사이의 숫자여야 합니다."; | ||
| private static final String LOTTO_BONUS_DUPLICATED_ERROR = "[ERROR] 당첨 번호 중 보너스 번호와 중복되는 번호가 존재합니다."; |
Member
There was a problem hiding this comment.
ErrorCode를 따로 enum으로 나누는것이 깔끔할것같습니다.
Comment on lines
+30
to
+32
| public int getReword() { | ||
| return reword; | ||
| } |
| public static final int LOTTO_PRICE = 1000; | ||
|
|
||
| private final int lottoCount; | ||
| private final List<Lotto> lottoSet = new ArrayList<>(); |
Member
There was a problem hiding this comment.
List 는 Lottos 나 LottoList로 표현하는게 알맞는 명명법 같습니다.
Comment on lines
+68
to
+72
| // 보너스 번호 포함 여부 확인 | ||
| private boolean isContainBonus(List<Integer> lottoNumber, int bonus, int match) { | ||
| if (match != 5) return false; | ||
| return lottoNumber.contains(bonus); | ||
| } |
Member
There was a problem hiding this comment.
Validation 클래스에 있어야할 메서드 같습니다
Comment on lines
+42
to
+46
| private void printLottoResult(PurchasedLotto purchasedLotto, WinningLotto winningLotto) { | ||
| Map<WinningRank, Integer> winningResult = calculateResult(purchasedLotto.getLottoSet(), winningLotto); | ||
| double returnRate = calculateReturnRate(purchasedLotto.getPurchaseAmount(), winningResult); | ||
| OutputView.printWinningResult(winningResult, returnRate); | ||
| } |
Member
There was a problem hiding this comment.
printLottoResult 과 printWinningResult 으로 메소드를 나눈 이유가 뭔가요??
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.
안녕하세요
코드에 아직 부족한 점이 많습니다
많은 피드백 부탁 드립니다!