[OptimistLabyrinth] ๐ 5๋จ๊ณ - ๋ก๋(์๋)#949
[OptimistLabyrinth] ๐ 5๋จ๊ณ - ๋ก๋(์๋)#949OptimistLabyrinth wants to merge 5 commits intonext-step:optimistlabyrinthfrom
Conversation
LottoGeneratorFromWinningNumbers ํด๋์ค์์ ํ์ธํ๋ ๋ก์ง์ Lotto ํด๋์ค ์์ฑ์์์ ํ์ธํ๋๋ก ์ด๋
LottoCalculationUtils ํด๋์ค์ ์๋ getMatchCount ๋ฉ์๋๋ฅผ Lotto ํด๋์ค๋ก ์ด๋ setCountForEachWinningRank ๋ฉ์๋์์ ์์ธ ์ฒ๋ฆฌ ๋ถ์กฑ์ผ๋ก ๋ฐ์ํ๋ ๋ฒ๊ทธ ์์
seokhongkim
left a comment
There was a problem hiding this comment.
๊ธฐ์ฑ๋, 5๋จ๊ณ ๋ฏธ์
์ ๊ตฌํํด์ฃผ์
จ์ต๋๋ค. ๐
์ฝ๋๋ฅผ ๋ณด๊ณ ๊ถ๊ธํ ์ ๊ณผ ๊ณ ๋ฏผํด๋ณด์๋ฉด ๋์์ด ๋ ๊ฒ ๊ฐ์ ๋ด์ฉ์ ์ฝ๋ฉํธ๋ก ๋จ๊ฒผ์ต๋๋ค.
์ฝ๋ฉํธ ํ์ธ ๋ถํ๋๋ฆฝ๋๋ค. ๐
| this.lottoNumbers = lottoNumbers; | ||
| } | ||
|
|
||
| private void checkDuplicateNumberInList(List<LottoNumber> winningLottoNumbers) throws IllegalArgumentException { |
There was a problem hiding this comment.
IllegalArgumentException์RuntimeException์ด๋ ๋ช ์์ ์ธ throws ๊ตฌ๋ฌธ์ด ์์ด๋ ๋ ๊ฒ ๊ฐ์์.- ์ฐ์น ๋ฒํธ๋ฅผ ์ ์ฅํ ๋๋
Lotto๋ฅผ ์ฌ์ฉํ์ง๋ง, ๊ตฌ๋งคํ ๋ก๋๋ฅผ ๊ด๋ฆฌํ ๋๋Lotto๋ฅผ ์ฌ์ฉํ๋ ๊ฒ ๊ฐ์์. ๊ทธ๋ผwinningLottoNumbers๋ณด๋ค๋lottoNumbers๊ฐ ์กฐ๊ธ ๋ ์ ์ค๋ช ํด์ฃผ๋ ๋ณ์ ์ด๋ฆ์ผ ๊ฒ ๊ฐ๋ค์! ์์ธ ๋ฉ์์ง๋ ๋น์ฒจ ๋ฒํธ๊ฐ ์๋ ๋ก๋ ๋ฒํธ๊ฐ ์ ์ ํ ๊ฒ ๊ฐ์ต๋๋ค. :)
| return lottoNumbers; | ||
| } | ||
|
|
||
| public int getMatchCount(Lotto other) { |
There was a problem hiding this comment.
๋ก๋๊ฐ ์ค์ค๋ก ๋ค๋ฅธ ๋ก๋์ ์ผ์นํ๋ ๋ฒํธ์ ๊ฐ์๋ฅผ ์นด์ดํธํ ์ ์์ด์, ๋ฅ๋์ ์ธ ๊ฐ์ฒด ์ญํ ์ ํ ์ ์๊ฒ ๋ ๊ฒ ๊ฐ๋ค์!
| @Override | ||
| public String toString() { | ||
| return lottoNumbers.toString(); | ||
| final List<LottoNumber> listToPrint = new ArrayList<>(lottoNumbers); |
There was a problem hiding this comment.
๋ก๋์ ์
์ถ๋ ฅ์ ์ฝ์์์ ์น์ผ๋ก ๋ณ๊ฒฝํ๋ค๊ณ ์์ํด๋ณด๋ฉด ์ด๋จ๊น์?
ํ์ฌ๋ ์ฝ์์ ์ถ๋ ฅํ๊ณ ์๊ธฐ์ toString์์ ๊ตฌํํด๋ ๊ด์ฐฎ์ง๋ง, ์น์ผ๋ก ๋ณ๊ฒฝ์ด ๋๋ค๋ฉด ์ ๋ ฌํด์ ๋ณด์ฌ์ฃผ๋ ๊ฒ์ ํ๋ฉด์ ์๊ตฌ์ฌํญ์ด ๋ ์ ์๊ฒ ๋ค์. ์๋๋ฉด ํ๋ฉด์ ๋ณด์ฌ์ค ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ๋(e.g., dto ๋ก ๋ณํํ ๋, ๋๋ getSortedLottoNumbers์ ๊ฐ์ ๋ช
์์ ์ธ ๋ฉ์๋๋ฅผ ํตํด ํธ์ถ๋ ๋) ์ ๋ ฌ์ ํ๋ ๋ฐฉ๋ฒ๋ ์์ ๊ฒ ๊ฐ์์.
์ ์๊ฐ์๋ toString์ ํ๋ฉด ์ถ๋ ฅ์ ์ํ ์๊ตฌ์ฌํญ์ ๊ตฌํํ๊ฒ ๋๋ฉด, ๋๋ฉ์ธ์ด ํ๋ฉด์ ๋ํ ๋ด์ฉ์ ์๊ฒ ๋๋ฏ๋ก ui์ ์์กด์ ์ธ ์ฝ๋๊ฐ ๋ ์ ์์ต๋๋ค. :) ์ด ๋ก์ง์ ๊ทธ๋๋ก OutputView์์ ๊ตฌํํด๋ณด์
๋ ์ข์ ๊ฒ ๊ฐ์์.
| return bonusNumber; | ||
| } | ||
|
|
||
| public void setBonusNumber(LottoNumber bonusNumber) { |
There was a problem hiding this comment.
WinningLotto ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ์์ ์ bonusNumber๋ ์ธ์๋ก ์ ๋ฌ ๋ฐ์ผ๋ฉด ์ด๋จ๊น์?
๊ทธ๋ผ WinningLotto๋ฅผ ๋ถ๋ณ ๊ฐ์ฒด๋ก ๊ด๋ฆฌํ ์ ์๊ณ , bonusNumber๋ lotto์ ์๋ ๋ฒํธ๊ฐ ๋ ์ ์๋ค(๋น์ฒจ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๋ ์ค๋ณต๋ ์ ์์ผ๋๊น์)๋ ๋ฐธ๋ฆฌ๋ฐ์ด์
๋ ํ ์ ์์ผ๋ฉฐ, ์์ฑ์๋ ๊ฐ์ฒด๊ฐ ์์ฑ๋ ๋ ํ์ํ ์กฐ๊ฑด์ ๋ชจ๋ ๊ด๋ฆฌํ ์ ์๊ฒ ๋ค์!
๋ณด๋์ค ๋ฒํธ๊ฐ ๋น์ฒจ๋ฒํธ์ ์ค๋ณต๋ ์ ์๋ค๋ ๋ฐธ๋ฆฌ๋ฐ์ด์ ๋ ์ถ๊ฐํด๋ณด์๋ฉด ์ข๊ฒ ์ต๋๋ค. :)
| return inputView.inputManyManualLotto(lottoCount); | ||
| } | ||
|
|
||
| private int getAutomaticLottoCount(MoneyToBuy moneyToBuy, ManualLottoCount manualLottoCount) { |
There was a problem hiding this comment.
์๋ ๊ตฌ๋งค ์๋๋งํผ ์ ์ธํ๊ณ ์๋ ๊ตฌ๋งค ์๋์ ๊ณ์ฐํ๋ ๊ฒ ์ ๊ตฌํํด์ฃผ์
จ์ต๋๋ค. ๐
์๋ ๊ตฌ๋งค ์๋์ ๊ฐ ๊ฐ์ฒด๋ก ๋ง๋์๊ณ , ์๋ ๊ตฌ๋งค ์๋์ int ํ์
์ผ๋ก ๊ด๋ฆฌํ์ ์ด์ ๊ฐ ์๋์ง ๊ถ๊ธํ๋ค์!
| return inputView.inputManualCount(moneyToBuy); | ||
| } | ||
|
|
||
| private List<Lotto> acceptManyManualLotto(ManualLottoCount lottoCount) { |
There was a problem hiding this comment.
Many๋ ๋ช ๊ฐ๋ฅผ ์๋ฏธํ ๊น์? 0๊ฐ๋ฅผ ๊ตฌ๋งคํ๋ ๊ฒฝ์ฐ์๋ ์ด ๋ฉ์๋๋ ํธ์ถ๋ ์ ์์ง ์์๊น์? :)
๋ณดํต ๋ณต์๊ฐ๋ฅผ ๋ํ๋ผ ๋๋ s๋ฅผ ๋ถ์ฌ์ ํํํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์๋ฅผ ๋ค๋ฉด, acceptManualLottos, generateAutomaticLottos, displayLottos์ ๊ฐ์ด ๋ณ๊ฒฝํด๋ณผ ์ ์๊ฒ ์ต๋๋ค.
| displayAllLotto(manualLottoCount, automaticLottoCount, lottoBucket); | ||
| final WinningLotto winningLotto = acceptWinningNumbers(); | ||
| acceptBonusNumber(winningLotto); | ||
| final Map<WinningRank, Integer> result = calculateLotto(lottoBucket, winningLotto); |
There was a problem hiding this comment.
์ด์ PR์ ์ฝ๋ฉํธ ๋จ๊ฒจ์ฃผ์ ๋ถ๋ถ์ ๋ํด ๋ต๋ณ ๋๋ฆฝ๋๋ค. :)
๊ทธ๋ฐ๋ฐ WinningRank Enum ์์ LottoPrize Enum ์ ์๋ ๊ฐ์ ์ฌ์ฉํ๋ค๋๊ฒ
์ด๋ค๊ฑด์ง ์ ๊ฐ์ด ์ ์ต๋๋ค.
์กฐ๊ธ ๋ ํํธ๋ฅผ ์ฃผ์ค ์ ์๋์???
ํ์ฌ calculateLotto์์ ๋ฑ์ ๊ณ์ฐ์ ์ ์ฅํ๊ธฐ ์ํด WinningRank๋ฅผ ์ฌ์ฉํ๊ณ ์๋๋ฐ, WinningRank ๋์ LottoPrize๋ฅผ ํค๋ก ์ฌ์ฉํด๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์์. WinningRank๋ฅผ ์ฌ์ฉํ๊ณ ์๋ ๋ชจ๋ ๋ถ๋ถ์ LottoPrize๊ฐ ๋ค์ด๊ฐ๋ ์ฝ๋๊ฐ ์ ๋์ํ๋๋ก ๊ตฌํ์ด ๊ฐ๋ฅํ ๊ฒ ๊ฐ์ต๋๋ค. :)
WinningRank์๋ ๋ฑ์์ ๋งค์น๋๋ ๊ฐ์๋ฅผ ๊ด๋ฆฌํ๊ณ ์๋๋ฐ์. 1. calculateLotto์์ ์ด ๊ฐ์ ์ฌ์ฉํ์ง ์๊ณ ์์ต๋๋ค. 2. ์ด ๊ฐ์ ์ฌ์ฉํ๋๋ผ๋, LottoPrize์์๋ ๋์ผํ๊ฒ ๋ฑ์์ ๋งค์น๋๋ ๊ฐ์๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฏ๋ก, LottoPrize์ ์๋ ๊ฐ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์, WinningRank ๋์ LottoPrize์ ๊ฐ์ ์ฌ์ฉํ๊ณ , WinningRank ํด๋์ค๋ ์ญ์ ํด๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค.
์ฝ๋์ ๋ํ ์ฝ๋ฉํธ์ ๋ณ๊ฐ๋ก enum ์ ํ์ฉ๋ฒ์ ๋์ค์ ์๊ฐ์ด ๋์ค ๋ ํ์ตํด๋ณด์๋ฉด ๋์์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค.
enum์ ์ฃผ๋ก ์์๋ฅผ ์ ์ํ ๋ ์ฌ์ฉํ๊ธฐ๋ ํ์ง๋ง, enum์ ์ ์๋ ๊ฐ์ ๋ชจ๋ ํ๋์ ๊ฐ์ฒด์ด๋ฏ๋ก, ์ด ์ ์ ์ ์ฌ์ฉํ๋ฉด ์กฐ๊ธ ๋ ๋ณ๊ฒฝ์ ์ ์ฐํ๊ฒ ๋์ํ ์ ์๋ ์ฝ๋๋ฅผ ์์ฑํ ์ ์์ต๋๋ค. enum ์ผ๋ก ์ฑ๊ธํด ํจํด ๊ตฌํํ๊ธฐ, enum ์ผ๋ก ์ ๋ต ํจํด ๊ตฌํํ๊ธฐ ๋ฑ์ ํค์๋๋ก ํ์ตํด๋ณด์๋ฉด ๋์์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค. :)
No description provided.