Conversation
| PurchaseAmountValidator.validateDividedByUnit(amount); | ||
| return new PurchaseAmount(amount); | ||
| } | ||
|
|
There was a problem hiding this comment.
validate로직을 lotto 도메인과 다르게 개별 클래스로 분리를 한 이유가 있을까요?
| validate(numbers); | ||
| this.numbers = numbers; | ||
| } | ||
|
|
There was a problem hiding this comment.
number를 별도의 클래스로 묶어주고 이를 vo로 설정해주면 비교가 편해질것 같아요
| } | ||
|
|
||
| public static Lottos from(List<Lotto> lottos) { | ||
| return new Lottos(lottos); |
There was a problem hiding this comment.
생성자와 똑같은 역할을 하는 정적 팩토리 메서드가 필요하진 않을 것 같습니다!
| } | ||
|
|
||
| public static void validateBonusNumber(Lotto winningNumbers, int bonusNumber) { | ||
| validateRange(bonusNumber); |
There was a problem hiding this comment.
bonusNumber를 LottoNumber와 같은 VO로 만들어서
1~45 사이의 숫자라는 것을 자체 검증하게 만들 수 있을거 같아요
| } | ||
|
|
||
| private static void validateDuplicate(Lotto winningNumbers, int bonusNumber) { | ||
| if (winningNumbers.getNumbers().contains(bonusNumber)) { |
There was a problem hiding this comment.
winningNumbers.contains(bonusNumber) 와 같은 식으로 구성할 수 있을 거 같습니다
| } | ||
|
|
||
| private void validateDuplicates(List<Integer> numbers) { | ||
| HashSet<Integer> uniqueNumbers = new HashSet<>(numbers); |
There was a problem hiding this comment.
private boolean isDuplicated(List<Integer> numbers){
return new HashSet<>(numbers)
.size() < numbers.size();
}
if(isDuplicated(numbers)){
...
}
이렇게 구성할 수 있을 거 같아요
|
|
||
| public int getBonusNumber() { | ||
| return bonusNumber; | ||
| } |
There was a problem hiding this comment.
WinningLotto 가 객체로서 하는 일이 많지 않은 것 같습니다.
책임을 더 부여해보는건 어떨까요?
| List<Integer> numbers = Randoms.pickUniqueNumbersInRange(MIN_LOTTO_NUMBER, MAX_LOTTO_NUMBER, LOTTO_NUMBERS_SIZE); | ||
| List<Integer> sortedNumbers = new ArrayList<>(numbers); | ||
| Collections.sort(sortedNumbers); | ||
| return sortedNumbers; |
| return readUserInput(() -> { | ||
| long input = inputView.readPurchaseAmount(); | ||
| return PurchaseAmount.from(input); | ||
| }); |
| return Stream.generate(() -> new Lotto(LottoNumbersGenerator.generate())) | ||
| .limit(quantity) | ||
| .toList(); | ||
| } |
There was a problem hiding this comment.
하나의 역할만 한다면 컨트롤러에서 처리해도 될 것 같습니다.
| private static final String RESULT_FORMAT_BONUS_MATCH = "%d개 일치, 보너스 볼 일치 (%,d원) - %d개"; | ||
| private static final int RANK_NEEDS_BONUS = 5; | ||
| private static final String PROFIT_FORMAT = "총 수익률은 %,.1f%%입니다."; | ||
|
|
There was a problem hiding this comment.
이렇게 상수가 많은 경우 클래스 하나 빼도 좋을 것 같습니다.
3시간 정도 소요