-
Notifications
You must be signed in to change notification settings - Fork 108
[그리디] 김민욱 로또 미션 3,4,5 단계 제출합니다. #170
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
base: hapdaypy
Are you sure you want to change the base?
Changes from 69 commits
adf5bbd
48c77a2
474aadd
b5eb6ff
381d67b
d4c2f13
15b6263
d5fff4a
b0d1d45
84eb0a5
c5de9ef
a5a6c94
4200424
96c0a6d
1a69d0a
41c7019
e37570e
bf79e60
ab9294d
b2c9729
71766eb
3b833ed
1cf15ec
0df50c8
6e69fda
1dc050d
35e644e
99e7044
b469635
1bc2243
1bc0835
4429df3
33c6110
978b639
5e9291d
167c8b0
f22c39d
9c7c8f2
a41be4e
e97bb51
ff87d7b
bdccdfe
06e66e3
9b880d8
5db58c1
f1dbc56
40664db
9182842
b0e11d8
d50e676
cdf6530
817ecf1
3b3bdd5
49c6584
5e3513c
df71a62
c31ec9e
7ec8baa
602d461
2a62420
0e8d69b
8f6e8c1
38307a5
96aeb0d
af13a01
63e613b
a5fa889
3df98b3
4135454
d7fafe3
1649b26
22d4d73
5b1ddd0
cccc8b0
f43ffd4
ec91681
98ee0ee
26cc5de
6c39761
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| * **[1] 구입 금액 입력 및 시도 횟수 계산** | ||
| * 숫자 형식, 1,000원 단위, 0 이하 값 입력 시 `IllegalArgumentException` 발생 및 재시도. | ||
| * **[2] 수동 로또 개수 입력 및 번호 생성** | ||
| * 총 발행 횟수 초과 및 음수 입력 검증. | ||
| * 1~45 범위의 중복되지 않는 6개 숫자 입력 검증. | ||
| * **[3] 자동 로또 번호 생성** | ||
| * 총 횟수에서 수동 횟수를 제외한 만큼 `RandomLottoNumberGenerator`를 통해 번호 자동 생성 및 오름차순 정렬. | ||
| * **[4] 로또 발급 내역 출력** | ||
| * 수동 및 자동 발급 수량과 전체 로또 번호 리스트 출력. | ||
| * **[5] 당첨 번호 및 보너스 번호 입력** | ||
| * 우승 로또 번호 입력 검증. | ||
| * 보너스 번호의 범위(1~45) 및 당첨 번호와의 중복 여부 검증. | ||
| * **[6] 당첨 결과 계산 및 통계 출력** | ||
| * `LottoResult`와 `Rank` Enum을 활용하여 일치 개수 및 상금 계산. | ||
| * 당첨 내역 출력 및 수익률(소수점 셋째 자리 내림 처리) 계산 후 출력. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import controller.Controller; | ||
|
|
||
| public class Application { | ||
| public static void main(String[] args) { | ||
| Controller controller = new Controller(); | ||
| controller.run(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| package controller; | ||
|
|
||
| import domain.Lotto; | ||
| import domain.LottoMachine; | ||
| import domain.LottoTickets; | ||
| import domain.TrialNumber; | ||
| import domain.LottoResult; | ||
| import domain.RandomLottoNumberGenerator; | ||
| import domain.validator.BonusNumberValidator; | ||
| import domain.validator.ManualCountValidator; | ||
|
|
||
| import view.InputView; | ||
| import view.OutputView; | ||
|
|
||
| import java.util.List; | ||
| import java.util.function.Supplier; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| public class Controller { | ||
|
|
||
| public void run() { | ||
| // [1] 구입 금액을 입력 받는다. | ||
| TrialNumber trialNumber = getTrialNumber(); | ||
| // [2] 수기로 입력할 로또 갯수를 입력 받는다. | ||
| int manualTrialCount = getManualTrialCount(trialNumber.getTrialNumber()); | ||
| // [3] 수기로 입력 받을 로또 번호를 입력 받는다. | ||
| LottoTickets manualTickets = getManualLottoTickets(manualTrialCount); | ||
| // [4] 자동으로 생성할 로또 번호를 계산한다. | ||
| int autoTrialCount = trialNumber.getTrialNumber() - manualTrialCount; | ||
| // [5] 자동 로또 번호를 생성한다. | ||
| LottoTickets autoTickets = issueLottoTickets(autoTrialCount, manualTrialCount); | ||
| // [6] 우승 로또 번호를 입력 받는다. | ||
| Lotto winningLotto = getWinningLotto(); | ||
| // [7] 보너스 번호를 입력받는다. | ||
| int bonusNumber = getBonusNumber(winningLotto); | ||
| // [8] 로또 결과를 계산한다. | ||
| LottoResult statisticsResult = calculateAndPrintResults(autoTickets, winningLotto, bonusNumber, manualTickets); | ||
| // [9] 최종 결과를 출력한다. | ||
| OutputView.printWinningStatistics(statisticsResult, trialNumber.getPurchaseAmount()); | ||
| } | ||
|
|
||
| private TrialNumber getTrialNumber() { | ||
| return retry(() -> { | ||
| OutputView.printInputPurchaseAmount(); | ||
| return new TrialNumber(InputView.inputPurchaseMoney()); | ||
| }); | ||
| } | ||
|
|
||
| private int getManualTrialCount(int totalTrialCount) { | ||
| return retry(() -> { | ||
| OutputView.printManualTrialCount(); | ||
| int manualCount = InputView.inputManualLottoNumberTrialCount(); | ||
| ManualCountValidator.validate(totalTrialCount, manualCount); | ||
| return manualCount; | ||
| }); | ||
| } | ||
|
|
||
| private LottoTickets getManualLottoTickets(int trialCount) { | ||
| if (trialCount == 0) { | ||
| return new LottoTickets(List.of()); | ||
| } | ||
| return retry(() -> { | ||
| OutputView.printManualLottoTickets(); | ||
| List<Lotto> manualLottos = IntStream.range(0, trialCount) | ||
| .mapToObj(i -> new Lotto(InputView.inputManualLottoNumber())) | ||
| .collect(Collectors.toList()); | ||
| return new LottoTickets(manualLottos); | ||
| }); | ||
| } | ||
|
|
||
| private LottoTickets issueLottoTickets(int trialCount, int manualCount) { | ||
| LottoMachine lottoMachine = new LottoMachine(new RandomLottoNumberGenerator()); | ||
| List<Lotto> generatedLottos = lottoMachine.issue(trialCount); | ||
| LottoTickets lottoTickets = new LottoTickets(generatedLottos); | ||
|
|
||
| OutputView.printLottoNumber(lottoTickets, trialCount, manualCount); | ||
| return lottoTickets; | ||
| } | ||
|
|
||
| private Lotto getWinningLotto() { | ||
| return retry(() -> { | ||
| OutputView.printInputWinningNumber(); | ||
| return new Lotto(InputView.inputWinningNumber()); | ||
| }); | ||
| } | ||
|
|
||
| private int getBonusNumber(Lotto winningLotto) { | ||
| return retry(() -> { | ||
| OutputView.printBonusNumber(); | ||
| int bonusNumber = InputView.inputBonusNumber(); | ||
| BonusNumberValidator.validate(winningLotto, bonusNumber); | ||
| return bonusNumber; | ||
| }); | ||
| } | ||
|
|
||
| private LottoResult calculateAndPrintResults(LottoTickets autoTickets, Lotto winningLotto, int bonusNumber, LottoTickets manualTickets) { | ||
| return new LottoResult(autoTickets, winningLotto, bonusNumber, manualTickets); | ||
| } | ||
|
|
||
| private <T> T retry(Supplier<T> supplier) { | ||
| try { | ||
| return supplier.get(); | ||
| } catch (IllegalArgumentException e) { | ||
| OutputView.printErrorMessage(e.getMessage()); | ||
| return retry(supplier); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package domain; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
|
|
||
| public class Lotto { | ||
| private static final int MIN_NUMBER = 1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정렬 단축키 한번만 눌러주세요~
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 윈도우 컴퓨터를 사용하고 있는데 단축키가 인텔리제에서 먹히는 게 아니라 다른 곳에서 먹힌다고 알고 있는데 최대한 빨리 개선해보겠습니다... |
||
| private static final int MAX_NUMBER = 45; | ||
| private static final int LOTTO_SIZE = 6; | ||
|
|
||
| private final List<Integer> lottoNumber; | ||
|
|
||
| public Lotto(List<Integer> lottoNumber) { | ||
| validate(lottoNumber); | ||
| validateRange(lottoNumber); | ||
| this.lottoNumber = lottoNumber; | ||
| } | ||
|
|
||
| private void validate(List<Integer> lottoNumber) { | ||
| if (lottoNumber.size() != LOTTO_SIZE) { | ||
| throw new IllegalArgumentException("[ERROR] 로또 번호는 6개여야 합니다."); | ||
| } | ||
| if (new HashSet<>(lottoNumber).size() != LOTTO_SIZE) { | ||
| throw new IllegalArgumentException("[ERROR] 로또 번호에 중복된 숫자가 있습니다."); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private void validateRange(List<Integer> lottoNumber) { | ||
| if (lottoNumber.stream().anyMatch(this::isOutOfRange)) { | ||
| throw new IllegalArgumentException("[ERROR] 로또 번호는 1부터 45 사이의 숫자여야 합니다."); | ||
| } | ||
| } | ||
|
|
||
| private boolean isOutOfRange(int number) { | ||
| return number < MIN_NUMBER || number > MAX_NUMBER; | ||
| } | ||
|
|
||
| public List<Integer> getNumbers() { | ||
| return Collections.unmodifiableList(lottoNumber); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package domain; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| public class LottoMachine { | ||
| private final LottoNumberGenerator generator; | ||
|
|
||
| public LottoMachine(LottoNumberGenerator generator) { | ||
| this.generator = generator; | ||
| } | ||
|
|
||
| public List<Lotto> issue(int trialCount) { | ||
| return IntStream.range(0, trialCount) | ||
| .mapToObj(i -> new Lotto(generator.generate())) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package domain; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface LottoNumberGenerator { | ||
| List<Integer> generate(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package domain; | ||
|
|
||
| import java.util.EnumMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class LottoResult { | ||
| private final Map<Rank, Integer> matchResults; | ||
| private final int bonusNumber; | ||
| private final int ZERO = 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금 코드로는 상수가 매 인스턴스마다 할당이 될 것 같아요! +) 추가적으로 민욱님만의 상수의 의미에 대해 묻고 싶어요!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. static 을 사용하는 것입니다 ! 예를 들어 MIN_LOTTO_NUMBER = 1이라고 선언하면, 이 숫자가 로또 번호의 최솟값이라는 의미가 분명하게 전달됩니다. 반면 현재 제 코드에 작성된 ZERO = 0은 숫자 자체를 영단어로 바꿨을 뿐, 값에 대한 어떠한 문맥적 의미도 부여하지 못한다고 판단했습니다. 따라서 다른 사람이 코드를 읽을 때 값의 의도를 납득할 수 있도록, INITIAL_NUMBER = 0과 같이 명확한 의미를 부여하는 방식으로 상수를 명명하겠습니다 ! |
||
| private final int ONE = 1; | ||
| private final int HUNDRED = 100; | ||
|
|
||
| public LottoResult(LottoTickets lottoTickets, Lotto winningLotto, int bonusNumber,LottoTickets manualLottoTickets) { | ||
| this.matchResults = new EnumMap<>(Rank.class); | ||
| this.bonusNumber = bonusNumber; | ||
| initResults(); | ||
| calculate(lottoTickets.getLottoNumber(), winningLotto.getNumbers(), this.bonusNumber, manualLottoTickets.getLottoNumber()); | ||
| } | ||
|
|
||
| private void initResults() { | ||
| for (Rank rank : Rank.values()) { | ||
| matchResults.put(rank, ZERO); | ||
| } | ||
| } | ||
|
|
||
| private void calculate(List<Lotto> lottoNumber, List<Integer> winningNumbers, int bonusNumber,List<Lotto> manullottoNumber) { | ||
| lottoNumber.forEach(lotto -> updateMatchResult(lotto, winningNumbers, bonusNumber)); | ||
| manullottoNumber.forEach(lotto -> updateMatchResult(lotto, winningNumbers, bonusNumber)); | ||
|
|
||
| } | ||
|
|
||
| private void updateMatchResult(Lotto lotto, List<Integer> winningNumbers, int bonusNumber) { | ||
| int matchCount = countMatch(lotto.getNumbers(), winningNumbers); | ||
| boolean matchBonus = lotto.getNumbers().contains(bonusNumber); | ||
| Rank rank = Rank.valueOf(matchCount, matchBonus); | ||
| matchResults.put(rank, matchResults.get(rank) + ONE); | ||
| } | ||
|
|
||
| private int countMatch(List<Integer> lottoNumber, List<Integer> winningNumbers) { | ||
| return (int) lottoNumber.stream() | ||
| .filter(winningNumbers::contains) | ||
| .count(); | ||
| } | ||
|
|
||
| public double calculateProfitRate(int purchaseAmount) { | ||
| long totalPrize = ZERO; | ||
| for (Map.Entry<Rank, Integer> entry : matchResults.entrySet()) { | ||
| totalPrize += (long) entry.getKey().getPrizeMoney() * entry.getValue(); | ||
| } | ||
| double rawProfitRate = (double) totalPrize / purchaseAmount; | ||
| return Math.floor(rawProfitRate * HUNDRED) / 100.0; | ||
| } | ||
|
|
||
| public int getRankCount(Rank rank) { | ||
| return matchResults.get(rank); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package domain; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class LottoTickets { | ||
| private final List<Lotto> lottoTickets; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 일급 컬렉션으로 만들어주신 것 같아요! 다만, 민욱님이 생각하는 일급 컬렉션의 의미는 무엇이고 언제 일급 컬렉션으로 관리하나요?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 생각하는 일급 컬렉션은 기본 컬렉션을 객체로 한 번 더 포장(Wrapping)하여 캡슐화한 클래스입니다. List generatedLottos 자체는 단순히 객체를 담은 자바의 기본 컬렉션이라고 생각했습니다. 그렇기 때문에 LottoTickets 클래스로 한 번 더 포장하여 값을 스스로 보장하고 캡슐화된 안전한 일급 컬렉션을 만들었습니다 ! 이렇게 만들어진 일급 컬렉션을 사용하면 Controller와 Domain 계층 간에 값을 전달할 때 안전하며, 원하는 정보의 출력, 저장, 가공 등 유지보수 측면에서 이점을 얻을 수 있다고 판단했습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정의를 잘 정리해주셔서 이해하기 쉬웠어요! 특히 "값을 스스로 보장하고 캡슐화된 안전한"이라는 표현이 아주 정석이군요 👍 그럼 그 정의를 가지고 지금 코드를 한번 봐보도록 할게요. 그렇다면 질문을 드려볼게요. 민욱님이 정의하신 "값을 스스로 보장하고 캡슐화된" 일급 컬렉션이라면, 두 묶음을 하나로 합치는 책임은 어디에 있어야 자연스러울까요? |
||
|
|
||
| public LottoTickets(List<Lotto> lottoTickets) { | ||
| this.lottoTickets = lottoTickets; | ||
| } | ||
|
|
||
| public List<Lotto> getLottoNumber() { | ||
| return Collections.unmodifiableList(lottoTickets); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package domain; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class RandomLottoNumberGenerator implements LottoNumberGenerator { | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 개행이 두개 들어가있네요~
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 확인했습니다! |
||
|
|
||
| private static final int MIN_LOTTO_NUMBER = 1; | ||
| private static final int MAX_LOTTO_NUMBER = 45; | ||
| private static final int LOTTO_NUMBER_COUNT = 6; | ||
|
|
||
| private final List<Integer> lottoPool; | ||
|
|
||
| public RandomLottoNumberGenerator() { | ||
| this.lottoPool = new ArrayList<>(); | ||
| for (int i = MIN_LOTTO_NUMBER; i <= MAX_LOTTO_NUMBER; i++) { | ||
| lottoPool.add(i); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public List<Integer> generate() { | ||
| Collections.shuffle(lottoPool); | ||
| List<Integer> selectedNumbers = new ArrayList<>(lottoPool.subList(0, LOTTO_NUMBER_COUNT)); | ||
| Collections.sort(selectedNumbers); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정렬은 도메인의 책임일까요? 민욱님은 어떻게 생각하시나요?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정렬은 도메인의 책임입니다 !
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (진짜 단순히 궁금해서 더 여쭤봅니다 ㅎ.ㅎ 민욱님 의견을 펼쳐주세요) 민욱님의 답변을 토대로 생각해보면 정렬 = 비지니스 로직 이라고 말씀해주신 것 같아요!
정렬이 되지 않으면 도메인 객체가 구체적으로 어떤 올바르지 않은 상태에 놓이게 되나요? 🤔
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제 의견을 리뷰어님에게 전달할 수 있게 되어 영광입니다....... 😆 이전에 제가 "정렬은 데이터를 이동시키기 때문에 비즈니스 로직이다"라고 자신 있게 말씀드렸던 부분은 다소 단편적인 주장이었습니다. 다시 깊게 생각해 본 결과, 정렬의 책임에는 정해진 정답이 없으며 요구사항에 따라 도메인에 있을 수도 있고 View 계층에 있을 수도 있다고 제 생각을 정정하고 싶습니다!
이번 미션에 한정해서 생각해 보면, 로또 번호를 정렬하는 작업이 도메인의 핵심 계산 로직에는 아무런 영향을 주지 않습니다! 따라서 단순 출력을 위한 정렬이라면 View 계층에서 처리해도 문제가 되지 않는다고 판단했습니다. "정렬은 무조건 도메인의 역할이다!"라는 이전의 제 주장을 철회하고, 상황과 요구사항의 목적에 맞게 책임을 분리해야 한다는 점을 깨닫게 되었습니다... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 단순히 상황과 요구사항에 따라 책임의 위치가 달라질 수 있다고 말씀해주신 게 아니라, 생각은 언제든 정정될 수 있는 것이니~, 다음에도 주저하지 말고 민욱님의 의견을 피력해주세요!! ㅎㅎ |
||
| return selectedNumbers; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package domain; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public enum Rank { | ||
| NONE(0, 0), | ||
| THREE(3, 5000), | ||
| FOUR(4, 50000), | ||
| FIVE(5, 1500000), | ||
| FIVE_BONUS(5, 30000000), | ||
| SIX(6, 2000000000); | ||
|
|
||
| private final int matchCount; | ||
| private final int prizeMoney; | ||
|
|
||
| Rank(int matchCount, int prizeMoney) { | ||
| this.matchCount = matchCount; | ||
| this.prizeMoney = prizeMoney; | ||
| } | ||
|
|
||
| public static Rank valueOf(int matchCount, boolean matchBonus) { | ||
| if (matchCount == 5 && matchBonus) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
추가로,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 방식대로라면 enum의 정체성이 외부 로직에 의해 판단될 수 있겠네요 ! 객체의 이름이 아닌 객체가 가진 조건을 만족하는 상태(값)를 기준으로 로직이 동작하게 설계를 하도록 하겠습니다 ! 시그니처가 다르더라도 혼동을 주는 것에 동의를 합니다 ! 메서드 이름을 다시 한 번 고민해야겠습니다 ! |
||
| return FIVE_BONUS; | ||
| } | ||
| return Arrays.stream(values()) | ||
| .filter(rank -> rank.matchCount == matchCount && rank != FIVE_BONUS) | ||
| .findFirst() | ||
| .orElse(NONE); | ||
| } | ||
|
|
||
| public static List<Rank> getWinningRanks() { | ||
| return Arrays.stream(values()) | ||
| .filter(rank -> rank != NONE) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public String getMessage() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getMessage() 의 호출에 대해서 해당 메서드가 어디에 있으면 좋을지 고민이 되었는데 메시지가 바뀌었을 때, 누가 수정이 되어야하는지에 대해서 생각해보니 getMessage()가 어디에 위치되어야 하는지에 대해서 정할 수 있었습니다 ! 메서드의 역할에 대해서 애매함을 느낄 때, 요구사항이 변경되면 어디에서 변경을 해줘야할 지에 대해서 고민함으로써 문제를 해결할 수 있겠네요 !! |
||
| if (this == FIVE_BONUS) { | ||
| return matchCount + "개 일치, 보너스 볼 일치 (" + prizeMoney + "원)- "; | ||
| } | ||
| return matchCount + "개 일치 (" + prizeMoney + "원)- "; | ||
| } | ||
|
|
||
| public int getPrizeMoney() { | ||
| return prizeMoney; | ||
| } | ||
|
|
||
| public int getMatchCount() { | ||
| return matchCount; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석을 사용해서 단계를 나눠주셨네요. 주석이 필요했던 이유가 무엇인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체적인 구조와 위임 흐름을 리뷰어님께서 빠르게 파악하실 수 있도록 진입점인 Controller 에 주석을 추가했습니다!
Controller 는 클라이언트 요청을 받아 Domain 및 View 계층으로 위임하는 역할을 하므로, 이곳에 호출 순서를 명시하는 것이 전체적인 의도 전달에 유리할 것이라 판단했습니다!!