Skip to content

[OptimistLabyrinth] ๐Ÿš€ 5๋‹จ๊ณ„ - ๋กœ๋˜(์ˆ˜๋™)#949

Open
OptimistLabyrinth wants to merge 5 commits intonext-step:optimistlabyrinthfrom
OptimistLabyrinth:feature/fifth_phase
Open

[OptimistLabyrinth] ๐Ÿš€ 5๋‹จ๊ณ„ - ๋กœ๋˜(์ˆ˜๋™)#949
OptimistLabyrinth wants to merge 5 commits intonext-step:optimistlabyrinthfrom
OptimistLabyrinth:feature/fifth_phase

Conversation

@OptimistLabyrinth
Copy link

No description provided.

OptimistLabyrinth added 5 commits November 26, 2022 21:53
LottoGeneratorFromWinningNumbers ํด๋ž˜์Šค์—์„œ ํ™•์ธํ•˜๋˜ ๋กœ์ง์„
Lotto ํด๋ž˜์Šค ์ƒ์„ฑ์ž์—์„œ ํ™•์ธํ•˜๋„๋ก ์ด๋™
LottoCalculationUtils ํด๋ž˜์Šค์— ์žˆ๋˜ getMatchCount ๋ฉ”์„œ๋“œ๋ฅผ
Lotto ํด๋ž˜์Šค๋กœ ์ด๋™

setCountForEachWinningRank ๋ฉ”์„œ๋“œ์—์„œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ๋ถ€์กฑ์œผ๋กœ ๋ฐœ์ƒํ•˜๋˜ ๋ฒ„๊ทธ ์ˆ˜์ •
Copy link

@seokhongkim seokhongkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ธฐ์„ฑ๋‹˜, 5๋‹จ๊ณ„ ๋ฏธ์…˜ ์ž˜ ๊ตฌํ˜„ํ•ด์ฃผ์…จ์Šต๋‹ˆ๋‹ค. ๐Ÿ‘
์ฝ”๋“œ๋ฅผ ๋ณด๊ณ  ๊ถ๊ธˆํ•œ ์ ๊ณผ ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋ฉด ๋„์›€์ด ๋  ๊ฒƒ ๊ฐ™์€ ๋‚ด์šฉ์„ ์ฝ”๋ฉ˜ํŠธ๋กœ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค.
์ฝ”๋ฉ˜ํŠธ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ๐Ÿ™

this.lottoNumbers = lottoNumbers;
}

private void checkDuplicateNumberInList(List<LottoNumber> winningLottoNumbers) throws IllegalArgumentException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. IllegalArgumentException์€ RuntimeException์ด๋‹ˆ ๋ช…์‹œ์ ์ธ throws ๊ตฌ๋ฌธ์ด ์—†์–ด๋„ ๋  ๊ฒƒ ๊ฐ™์•„์š”.
  2. ์šฐ์Šน ๋ฒˆํ˜ธ๋ฅผ ์ €์žฅํ•  ๋•Œ๋„ Lotto๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋งŒ, ๊ตฌ๋งคํ•œ ๋กœ๋˜๋ฅผ ๊ด€๋ฆฌํ•  ๋•Œ๋„ Lotto๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ๊ฐ™์•„์š”. ๊ทธ๋Ÿผ winningLottoNumbers๋ณด๋‹ค๋Š” lottoNumbers๊ฐ€ ์กฐ๊ธˆ ๋” ์ž˜ ์„ค๋ช…ํ•ด์ฃผ๋Š” ๋ณ€์ˆ˜ ์ด๋ฆ„์ผ ๊ฒƒ ๊ฐ™๋„ค์š”! ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๋„ ๋‹น์ฒจ ๋ฒˆํ˜ธ๊ฐ€ ์•„๋‹Œ ๋กœ๋˜ ๋ฒˆํ˜ธ๊ฐ€ ์ ์ ˆํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. :)

return lottoNumbers;
}

public int getMatchCount(Lotto other) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋กœ๋˜๊ฐ€ ์Šค์Šค๋กœ ๋‹ค๋ฅธ ๋กœ๋˜์™€ ์ผ์น˜ํ•˜๋Š” ๋ฒˆํ˜ธ์˜ ๊ฐœ์ˆ˜๋ฅผ ์นด์šดํŠธํ•  ์ˆ˜ ์žˆ์–ด์„œ, ๋Šฅ๋™์ ์ธ ๊ฐ์ฒด ์—ญํ• ์„ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ ๊ฒƒ ๊ฐ™๋„ค์š”!

@Override
public String toString() {
return lottoNumbers.toString();
final List<LottoNumber> listToPrint = new ArrayList<>(lottoNumbers);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋กœ๋˜์˜ ์ž…์ถœ๋ ฅ์„ ์ฝ˜์†”์—์„œ ์›น์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค๊ณ  ์ƒ์ƒํ•ด๋ณด๋ฉด ์–ด๋–จ๊นŒ์š”?
ํ˜„์žฌ๋Š” ์ฝ˜์†”์— ์ถœ๋ ฅํ•˜๊ณ  ์žˆ๊ธฐ์— toString์—์„œ ๊ตฌํ˜„ํ•ด๋„ ๊ดœ์ฐฎ์ง€๋งŒ, ์›น์œผ๋กœ ๋ณ€๊ฒฝ์ด ๋œ๋‹ค๋ฉด ์ •๋ ฌํ•ด์„œ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์€ ํ™”๋ฉด์˜ ์š”๊ตฌ์‚ฌํ•ญ์ด ๋  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”. ์•„๋‹ˆ๋ฉด ํ™”๋ฉด์— ๋ณด์—ฌ์ค„ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•  ๋•Œ(e.g., dto ๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ, ๋˜๋Š” getSortedLottoNumbers์™€ ๊ฐ™์€ ๋ช…์‹œ์ ์ธ ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด ํ˜ธ์ถœ๋  ๋•Œ) ์ •๋ ฌ์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”.

์ œ ์ƒ๊ฐ์—๋Š” toString์— ํ™”๋ฉด ์ถœ๋ ฅ์„ ์œ„ํ•œ ์š”๊ตฌ์‚ฌํ•ญ์„ ๊ตฌํ˜„ํ•˜๊ฒŒ ๋˜๋ฉด, ๋„๋ฉ”์ธ์ด ํ™”๋ฉด์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์•Œ๊ฒŒ ๋˜๋ฏ€๋กœ ui์— ์˜์กด์ ์ธ ์ฝ”๋“œ๊ฐ€ ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. :) ์ด ๋กœ์ง์„ ๊ทธ๋Œ€๋กœ OutputView์—์„œ ๊ตฌํ˜„ํ•ด๋ณด์…”๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”.

return bonusNumber;
}

public void setBonusNumber(LottoNumber bonusNumber) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WinningLotto ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์‹œ์ ์— bonusNumber๋„ ์ธ์ž๋กœ ์ „๋‹ฌ ๋ฐ›์œผ๋ฉด ์–ด๋–จ๊นŒ์š”?
๊ทธ๋Ÿผ WinningLotto๋ฅผ ๋ถˆ๋ณ€ ๊ฐ์ฒด๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ณ , bonusNumber๋Š” lotto์— ์žˆ๋Š” ๋ฒˆํ˜ธ๊ฐ€ ๋  ์ˆ˜ ์—†๋‹ค(๋‹น์ฒจ๋ฒˆํ˜ธ์™€ ๋ณด๋„ˆ์Šค ๋ฒˆํ˜ธ๋Š” ์ค‘๋ณต๋  ์ˆ˜ ์—†์œผ๋‹ˆ๊นŒ์š”)๋Š” ๋ฐธ๋ฆฌ๋ฐ์ด์…˜๋„ ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ƒ์„ฑ์ž๋Š” ๊ฐ์ฒด๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ํ•„์š”ํ•œ ์กฐ๊ฑด์„ ๋ชจ๋‘ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”!

๋ณด๋„ˆ์Šค ๋ฒˆํ˜ธ๊ฐ€ ๋‹น์ฒจ๋ฒˆํ˜ธ์™€ ์ค‘๋ณต๋  ์ˆ˜ ์—†๋‹ค๋Š” ๋ฐธ๋ฆฌ๋ฐ์ด์…˜๋„ ์ถ”๊ฐ€ํ•ด๋ณด์‹œ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค. :)

return inputView.inputManyManualLotto(lottoCount);
}

private int getAutomaticLottoCount(MoneyToBuy moneyToBuy, ManualLottoCount manualLottoCount) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๋™ ๊ตฌ๋งค ์ˆ˜๋Ÿ‰๋งŒํผ ์ œ์™ธํ•˜๊ณ  ์ž๋™ ๊ตฌ๋งค ์ˆ˜๋Ÿ‰์„ ๊ณ„์‚ฐํ•˜๋Š” ๊ฒƒ ์ž˜ ๊ตฌํ˜„ํ•ด์ฃผ์…จ์Šต๋‹ˆ๋‹ค. ๐Ÿ‘
์ˆ˜๋™ ๊ตฌ๋งค ์ˆ˜๋Ÿ‰์€ ๊ฐ’ ๊ฐ์ฒด๋กœ ๋งŒ๋“œ์‹œ๊ณ , ์ž๋™ ๊ตฌ๋งค ์ˆ˜๋Ÿ‰์€ int ํƒ€์ž…์œผ๋กœ ๊ด€๋ฆฌํ•˜์‹  ์ด์œ ๊ฐ€ ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•˜๋„ค์š”!

return inputView.inputManualCount(moneyToBuy);
}

private List<Lotto> acceptManyManualLotto(ManualLottoCount lottoCount) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many๋Š” ๋ช‡ ๊ฐœ๋ฅผ ์˜๋ฏธํ• ๊นŒ์š”? 0๊ฐœ๋ฅผ ๊ตฌ๋งคํ•˜๋Š” ๊ฒฝ์šฐ์—๋„ ์ด ๋ฉ”์„œ๋“œ๋Š” ํ˜ธ์ถœ๋  ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ์š”? :)
๋ณดํ†ต ๋ณต์ˆ˜๊ฐœ๋ฅผ ๋‚˜ํƒ€๋‚ผ ๋•Œ๋Š” s๋ฅผ ๋ถ™์—ฌ์„œ ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด, acceptManualLottos, generateAutomaticLottos, displayLottos์™€ ๊ฐ™์ด ๋ณ€๊ฒฝํ•ด๋ณผ ์ˆ˜ ์žˆ๊ฒ ์Šต๋‹ˆ๋‹ค.

displayAllLotto(manualLottoCount, automaticLottoCount, lottoBucket);
final WinningLotto winningLotto = acceptWinningNumbers();
acceptBonusNumber(winningLotto);
final Map<WinningRank, Integer> result = calculateLotto(lottoBucket, winningLotto);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด์ „ 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 ์œผ๋กœ ์ „๋žต ํŒจํ„ด ๊ตฌํ˜„ํ•˜๊ธฐ ๋“ฑ์˜ ํ‚ค์›Œ๋“œ๋กœ ํ•™์Šตํ•ด๋ณด์‹œ๋ฉด ๋„์›€์ด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants