[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๋ฒ ํ )] ์ ์ด์ฝฅ ๋ฏธ์ ์ ์ถํฉ๋๋ค.#1119
[๐ ์ฌ์ดํด2 - ๋ฏธ์
(๋ธ๋์ญ ๋ฒ ํ
)] ์ ์ด์ฝฅ ๋ฏธ์
์ ์ถํฉ๋๋ค.#1119Gomding merged 168 commits intowoowacourse:khcho96from
Conversation
โฆํ๋๋ก ๊ตฌํ ์์
โฆialScore() ๋ฉ์๋ ๊ตฌํ
โฆmeManager ๋ฉ์๋๋ช ๋ณ๊ฒฝ
Gomding
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์ ์ ์ด์ฝฅ!
๋ ๋ฐ์ํ๊ณ ์ถ์๊ฒ์ด ์๋ค๊ณ ์์ฒญํ์
์ ๋จธ์ง๋ ๋ณด๋ฅํ ๊ฒ์~
๋
ผ์ ํ์ํ ๋ถ๋ถ ์์ผ๋ฉด DM ์ด๋ ์ฝ๋ฉํธ ๋จ๊ฒจ์ฃผ์ธ์! ๐
| private final List<Player> players; | ||
|
|
||
| public Players(List<String> names) { | ||
| public Players(List<PlayerName> names, List<BetAmount> betAmounts) { |
| public final class BlackjackJudge { | ||
|
|
There was a problem hiding this comment.
BlackjackJudge ํด๋์ค๋ final ๋ก ๋ง๋ค์ด์ฃผ์ จ๋๋ฐ ์ด๋ค ์๋๋ก ๋ง๋ค์ด์ฃผ์ ๊ฑธ๊น์? ๐
| import domain.participant.Dealer; | ||
| import domain.participant.Player; | ||
|
|
||
| public final class BlackjackJudge { |
There was a problem hiding this comment.
BlackjackJudge ๋ ๊ฐ์ฒด ์์ฑ ์์ด static ๋ฉ์๋ ๋ง์ ๊ฐ์ง๋ util ํด๋์ค๋ก ์ฌ์ฉํด๋ ๋ ๊ฒ ๊ฐ์๋ฐ
ํด๋น ๋ถ๋ถ๋ ๊ณ ๋ฏผํด๋ณด์
จ์๊น์?
|
|
||
| public static final String INVALID_BET_AMOUNT_NUMBER = "๋ฐฐํ ๊ธ์ก์ ์ซ์์ฌ์ผ ํฉ๋๋ค."; | ||
| public static final String INVALID_BET_AMOUNT_POSITIVE = "๋ฐฐํ ๊ธ์ก์ ์์์ฌ์ผ ํฉ๋๋ค."; | ||
| public static final String INVALID_BET_AMOUNT_RANGE = "๋ฒ ํ ๊ธ์ก์ ๋ฒ์๊ฐ ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค. (1000 ์ด์ 3์ต ์ดํ์ ๊ธ์ก ์ ๋ ฅ)"; |
| public void drawInitialCards(Supplier<Card> cardSupplier) { | ||
| dealer.addCard(cardSupplier.get()); | ||
| dealer.addCard(cardSupplier.get()); | ||
| dealer.drawInitialCards(cardSupplier); |
โฆner๋ก ํด๋์ค๋ช ๋ณ๊ฒฝ
โฆํด๋์ค๋ช ๋ณ๊ฒฝ์ผ๋ก ์ธํ ์ฝ๋ ์์
|
|
||
| public final class BlackjackJudge { | ||
|
|
||
| public PlayerResult judgePlayerResult(Dealer dealer, Player player) { |
There was a problem hiding this comment.
๊ฐ๋
์ฑ์ ์ํด์
if ๋ฌธ์ 3๊ฐ๋ก๋ง ์ค์ฌ๋ณด๋๊ฒ๋ ๋ฐฉ๋ฒ์ผ ๊ฒ ๊ฐ์์
๊ฐ ๋ฉ์๋์์ ์ด๋ค ์ํฉ์ ํจ๋ฐฐ๋ก ํ๋จ๋๋์ง ๋ชจ์๋๋ฉด ๋ช
ํํ๊ฒ ํ์ธํ ์ ์๋ค๋ ์ฅ์ ์ด ์์ด์
if (isLose(dealer, player)) {
return PlayerResult.LOSE;
}
if (IsWin(dealer, player)) {
return PlayerResult.WIN;
}
if (IsBlackjackWin(dealer, player)) {
return PlayerResult.BLACKJACK_WIN;
}
if (isDraw(dealer, player)) {
return PlayerResult.DRAW;
}There was a problem hiding this comment.
๋ค์ ๋ฏธ์
์์๋ ์ปค๋ฐ์ ์คํ๊ฐ๋ฅํ ๋จ์๋ก ๋๋ ๋ณด๋๊ฒ๋ ๋์ ํด๋ณด์๋ฉด ์ข๊ฒ ์ด์ :)
์์ ์ ํ๋ค๋ฉด ์คํ์ ์ํ ์์ , ํ
์คํธ ์ฝ๋ ์คํ + ์์ ๋ฑ์ ๋ฌถ์ด์
๋ชจ๋ ์ปค๋ฐ๋ค์ด ์คํ ๊ฐ๋ฅํ ์ํ๋ก ๋ง๋๋๊ฒ์ด์ฃ
์ค์ ๋ก ๋ชจ๋ ์ปค๋ฐ์ ์คํ์ด ๊ฐ๋ฅํด์ผํ๋ค <-- ์ด๊ฒ ์ปค๋ฐ์ ์กฐ๊ฑด ์
๋๋ค :)
๋ฒ๊ทธ๊ฐ ์๋๋ฐ ์ปค๋ฐ์ ํด๋ฒ๋ ธ๋ค๋ฉด git commit --amend ๊ธฐ๋ฅ์ ํ์ตํด๋ณด์๊ณ ์ฌ์ฉํด๋ณด์ธ์!
Gomding
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์ ์ ์ด์ฝฅ!
๋ฏธ์
์งํํ๋๋ผ ๊ณ ์ํ์
จ์ด์ ๐ ๐ ๐
์ด๋ฏธ ๋ง์ ๊ณ ๋ฏผ๋ค์ ํด์ฃผ์
จ๋๋ฐ ์์ผ๋ก ๋ง์ ์ฑ์ฅ์ ์ด๋ฃจ์ค๊ฑฐ๋ผ ์๊ฐํด์~
์์ผ๋ก์ ์ฐํ ์ฝ ์ํฉ๋ ๋ฏธ์ ๋ ํ์ดํ ์ ๋๋ค! ๐ช

์ฒดํฌ ๋ฆฌ์คํธ
test๋ฅผ ์คํํ์ ๋, ๋ชจ๋ ํ ์คํธ๊ฐ ์ ์์ ์ผ๋ก ํต๊ณผํ๋์?์ด๋ค ๋ถ๋ถ์ ์ง์คํ์ฌ ๋ฆฌ๋ทฐํด์ผ ํ ๊น์?
์ฌ์ดํด1 ๋ง์ง๋ง ์ฝ๋ฉํธ์์ ๋ฐ์ํ ๋ด์ฉ
์ง๋ฌธ
์๋๋ ์ค๋ณต์ ๋ง๋ค๊ธฐ๋ ํ๋ค๋ ์ฌ์ค์ ์ถฉ๊ฒฉ์ ์ด๋ค์ ๐ฎ
"์ค๋ณต"์ ๋ํด 100% ๋ถ์ ์ ์ผ๋ก ๋ฐ๋ผ๋ดค์๋๋ฐ, ๊ทธ๋ ์ง ์์ ์๋ ์๋ค๋ ์ฌ์ค์ ์ธ์งํ๊ณ ์ ์ฐํ๊ฒ ์๊ฐํด๋ด์ผ๊ฒ ์ต๋๋ค!
ํ ๊ฐ์ง ๊ถ๊ธํ ์ ์ด ์๋๋ฐ, ์ฐฐ๋ฆฌ๋ constant ํจํค์ง๋ฅผ ์ฌ์ฉํ์๋ ํธ์ธ๊ฐ์?
๋ง์ฝ ์ฌ์ฉํ์ ๋ค๋ฉด ์ด๋ค ๊ฒฝ์ฐ์, ์ด๋ค ํด๋์ค๋ฅผ ๊ณตํต์ผ๋ก ๊ด๋ฆฌํ๋ constant ํจํค์ง๋ก ๋ถ๋ฆฌํ์๋์?
์ ๊ฐ ์๊ฐํ์ ๋ ํ์ฌ ์น๋ฌดํจ ํ๋จ์ ํ๋ ๋ฉ์๋๋ BlackjackGameManager ํด๋์ค์ getBlackjackStatistics ๋ฉ์๋ ๋ก์ง์ธ๋ฐ, ํนํ ํด๋น ๋ฉ์๋ ๋ด ์๋ 3์ค์ ๋ก์ง์ธ ๋ฏ ํฉ๋๋ค.
์ด ๋ก์ง์ ๊ฐ์ง๋ ๊ฐ์ฒด(A๋ผ๊ณ ์ง์นญํ๊ฒ ์ต๋๋ค)๋ฅผ ๋ฐ๋ก ๋ง๋ ๋ค๋ฉด A๋ judgePlayerResult ๋ฉ์๋์ calculatePlayerProfit ๋ฉ์๋๋ฅผ ํด๋์ค ๋ด์์ ๊ฐ์งํ ๋ฐ, ์ด๋ ๋ณด์๋ ๊ฒ์ฒ๋ผ ๋ฉ์๋์ ์ธ์๋ก Dealer์ Player๊ฐ ๋ค์ด๊ฐ๊ธฐ๋๋ฌธ์ A๊ฐ Dealer์ Player์๊ฒ ์์กดํ๊ฒ ๋๊ณ , ๊ฒฐํฉ๋๊ฐ ์ปค์ง๊ฒ ๋์ง ์์๊น๋ผ๋ ๋ถ๋ถ์ด ์ผ๋ ค๋ฉ๋๋ค. ๊ฒฐํฉ๋๊ฐ ์ปค์ง๋ฉด ์์ ๋ฒ์๊ฐ ์ปค์ง๊ฒ ๋๋ ๋จ์ ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์ด ๋ถ๋ถ์ ๋ํ ์ฐฐ๋ฆฌ์ ์๊ฒฌ์ด ๊ถ๊ธํฉ๋๋ค!
Rank ํด๋์ค์์ score์ ์์๊ฐ ํฌ์ฅ์ ๋ํด ๋ง์ํด์ฃผ์ จ๋๋ฐ, ๋จ์ํ ์์๋ฅผ ์ ์ฅํ๊ณ ์๊ณ ๋ธ๋์ญ ์ ์ ๊ท์น์ ๋ํ ๋ด์ฉ์ ๋ค๋ฅธ ๊ฐ์ฒด์์ ๋ฉ์๋๋ก ๊ตฌํํ๊ธฐ๋๋ฌธ์ score์์ ์ด๋ค ์ถ๊ฐ์ ์ธ ๊ท์น์ ๊ฒ์ฆํ๊ฑฐ๋ ๋ค๋ฃฐ์ง ์์ด๋์ด๊ฐ ๋ ์ค๋ฅด์ง ์๋ค์๐
ํน์ ์ฐฐ๋ฆฌ ์ ์ฅ์์ score๋ฅผ ์์๊ฐ ํฌ์ฅํ๋ค๋ฉด ์ด๋ค์์ผ๋ก ๊ตฌํํ์ค์ง ๊ถ๊ธํฉ๋๋ค!
1์ฐจ ํผ๋๋ฐฑ ์์ ์์
2์ฐจ ํผ๋๋ฐฑ ์์ ์์
3์ฐจ ํผ๋๋ฐฑ ์์ ์์
4์ฐจ ํผ๋๋ฐฑ ์์ ์์