[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๋ฒ ํ )] ์ ์ด์ฝฅ ๋ฏธ์ ์ ์ถํฉ๋๋ค.#1119
[๐ ์ฌ์ดํด2 - ๋ฏธ์
(๋ธ๋์ญ ๋ฒ ํ
)] ์ ์ด์ฝฅ ๋ฏธ์
์ ์ถํฉ๋๋ค.#1119khcho96 wants to merge 128 commits intowoowacourse:khcho96from
Conversation
โฆํ๋๋ก ๊ตฌํ ์์
โฆialScore() ๋ฉ์๋ ๊ตฌํ
โฆmeManager ๋ฉ์๋๋ช ๋ณ๊ฒฝ
โฆ cardMachine() ๋ฐ blackjackJudge() ๋ฉ์๋ ๊ตฌํ
โฆackGameManager๋ฅผ ์ธ์๋ก ๋๊ธฐ์ง ์๋๋ก ์์
โฆackjackGameManager๋ฅผ ์ธ์๋ก ๋๊ธฐ๋๋ก ์์
โฆper() ์ฌ์ฉํ๋๋ก ์์
โฆ private์ผ๋ก ๋ณ๊ฒฝ
Gomding
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์ ์ ์ด์ฝฅ!
ํผ๋๋ฐฑ ์ ๋ฐ์ํด์ฃผ์
จ๋ค์~
์ถ๊ฐ๋ก ์ฝ๋ฉํธ ๋จ๊ฒผ์ผ๋ ํ์ธ๋ถํ๋๋ ค์ :)
๊ถ๊ธํ ์ ์์ผ๋ฉด ์ธ์ ๋ DM ์ด๋ ์ฝ๋ฉํธ ๋จ๊ฒจ์ฃผ์ธ์
There was a problem hiding this comment.
-
์์กด์ด ์๋๊ฒ์ ์ด์ฉ ์ ์์ด BlackjackGameManager ์ ๋ณ๊ฒฝ์ ์ํฅ์ ๋ฐ์ ์ ๋ฐ์ ์๊ฒ ์ฃ :)
Controller ๊ฐ BlackjackGameManager ๋ฅผ ์์กดํ๋๊ฒ์ ๋น์ฐํ ์์กด์ด ์๋๊น์? ๐ค
์์กดํ์ง์๊ณ ๋ธ๋์ญ ๊ฒ์์ ํ๋๊ฒ ๊ฐ๋ฅํ ๊น์? ๐ -
Controller ๋ฅผ ์๋ก ์์ฑํ๋๊ฒ์ด ์์ฐ์ค๋ฝ๋์? BlackjackGameManager ๋ฅผ ์๋ก ์์ฑํ๋๊ฒ์ด ์์ฐ์ค๋ฝ๋์?
์ญํ ์ ๊ด์ ์์ ๊ณ ๋ฏผํด๋ณผ ์ ์๊ฒ ๋ค์. ์ ์ด์ฝฅ์ Controller ์ ์ญํ ์ ๋ฌด์์ผ๋ก ๋ณด๊ณ ์๋์?
++) start ์ ์ธ์๋ก ๋ฐ์์ผํ ์ด์ ๊ฐ ์์๊น์?
start ๋ด๋ถ์์ BlackjackGameManager ๋ฅผ ์์ฑํ๋ฉด ์ข์ ๊ฒ ๊ฐ์์ ๐ค
์ ๋ BlackjackGameManager ๋ฅผ Main ๊น์ง ๋
ธ์ถํ ํ์๊ฐ ์๋ค๊ณ ์๊ฐํด์์!
| public BlackjackGameManager blackjackGameManager() { | ||
| return new BlackjackGameManager(cardMachine(), blackjackJudge()); | ||
| } | ||
|
|
||
| private CardMachine cardMachine() { | ||
| return new CardMachine(); | ||
| } | ||
|
|
||
| private BlackjackJudge blackjackJudge() { | ||
| return new BlackjackJudge(); |
There was a problem hiding this comment.
BlackjackControllerFactory ๋ผ๋ ์ด๋ฆ์ ๋ณ๊ฒฝํ๋ฉด์๊น์ง
์ฌ๊ธฐ์ ๋๋ฉ์ธ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ์ฑ
์์ ์์นํ ์ด์ ๊ฐ ๊ถ๊ธํด์!
๊ผญ Factory ๊ฐ์ฒด๋ ํ๋๋ง ์กด์ฌํด์ผํ ๊น์?
๋๋ฉ์ธ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋๊ฒ์ domain ํจํค์ง์ ๋ฃ์ง์์ ์ด์ ๊ฐ ์์๊น์?
|
|
||
| private final CardMachine cardMachine; | ||
| private final BlackjackJudge blackjackJudge; | ||
| private Participants participants; |
There was a problem hiding this comment.
์์ฑ์์์ ์ด๊ธฐํํ์ง ์๋๊ฒ final ์ด ์๋ ์ด์ ์ ์ด์ด์ง ๊ฒ ๊ฐ๋ค์ :)
๋ถ๋ณ์ผ๋ก ๋ง๋๋๊ฒ์ ํญ์ ๊ณ ๋ คํด๋ณด์๋ฉด ์ข๊ฒ ์ด์!
| import domain.participant.Dealer; | ||
| import domain.participant.Player; | ||
|
|
||
| public record BlackjackJudge() { |
There was a problem hiding this comment.
record ์ธ ์ด์ ๊ฐ ์์๊น์?
์ ์ด์ฝฅ์ด ์๊ฐํ๋ record ๋ ์ด๋ค ๊ฐ์ฒด์ธ๊ฐ์? ๐ค
| public boolean playerIsBust(String name) { | ||
| return participants.playerIsBust(name); | ||
| } |
There was a problem hiding this comment.
isPlayerBust ๋ก ์ด๋ฆ์ ๋ณ๊ฒฝํ๋ฉด ์ข์๊ฒ ๊ฐ์์!
โฆpants ํ๋ final ์ง์ ์ผ๋ก ์์ฑ์์์ ๊ฐ ํ ๋น๋๋๋ก ์์
โฆackjackJudge() ๋ฉ์๋ ์ญ์
blackjackGameManager() ํธ์ถ ์ ๊ฑฐ
Gomding
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์ ์ ์ด์ฝฅ~
์ด์ ์ฝ๋ฉํธ ๋จ๊ธธ๊ฒ์ด ๊ฑฐ์ ์๋ค์
์ถ๊ฐ๋ก ์ฝ๋ฉํธ ๋จ๊ฒผ์ผ๋ ํ์ธ๋ถํ๋๋ ค์!
๋ค์ ์์ฒญ์๋ ๋จธ์งํ ๊ฒ ๊ฐ์๋ฐ ์ถ๊ฐ๋ก ๊ถ๊ธํ ๋ถ๋ถ์์ผ๋ฉด ์๋ ค์ฃผ์ธ์ :)
| public BlackjackGameManager(CardMachine cardMachine, BlackjackJudge blackjackJudge) { | ||
| public BlackjackGameManager(CardMachine cardMachine, BlackjackJudge blackjackJudge, Participants participants) { |
There was a problem hiding this comment.
์ฝ๋ฉํธ ๋๋ฆฐ ์ด์ ๋ ๊ฐ์ฒด๋ ์์ ํ ์ํ๋ก ์ด๊ธฐํ ํด์ฃผ๋๊ฒ ์ข๋ค๊ณ ์๊ฐํด์
์ผ๋ถ ํ๋๋ฅผ ๋์ค์ ์ด๊ธฐํ ํ๋๊ฒ์ ์ฒ์ ๊ฐ์ฒด ์์ฑ ์ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ ์ ์๋ ์ํ์ธ์ง ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข์์
๋ฌผ๋ก ๋์ค์ ์ด๊ธฐํํ๋ ๊ฒฝ์ฐ๊ฐ ์์ ์๋๊ฒ์ ์๋๋๋ค! ๐
| if (player.calculateScore() == dealer.calculateScore()) { | ||
| return Result.DRAW; |
There was a problem hiding this comment.
๋๋ฌ๊ฐ ๋ธ๋์ญ ์ด๊ณ ํ๋ ์ด์ด๊ฐ ์ผ๋ฐ 21์ ์ผ ๋ ๋ฌด์น๋ถ๋ก ํ๋จ๋ ์ ์๊ฒ ๋ค์!
| public static final String INVALID_BET_AMOUNT_POSITIVE = "๋ฐฐํ ๊ธ์ก์ ์์์ฌ์ผ ํฉ๋๋ค."; | ||
| private static final String NUMBER_FORMAT = "-?\\d+"; | ||
|
|
||
| private final int betAmount; |
There was a problem hiding this comment.
๋ฒ ํ ๊ธ์ก์ ๋ํด์ int, long BigDecimal, BigInteger ๋ฑ์ ํ์ ๋ ๊ณ ๋ฏผํด๋ณด์ จ์๊น์?
| private final List<Player> players; | ||
|
|
||
| public Players(List<String> names) { | ||
| public Players(List<PlayerName> names, List<BetAmount> betAmounts) { |
There was a problem hiding this comment.
์ ๋ ฅ๋ฐ์ names ์ betAmounts ์ size ์ ๋ํ ๊ฒ์ฆ๋ ์์ด์ผ๊ฒ ๊ตฐ์ ๐ค
| dealer.addCard(cardSupplier.get()); | ||
| dealer.addCard(cardSupplier.get()); |
There was a problem hiding this comment.
dealer ์๊ฒ 2๋ฒ ์์ฒญํ์ง์๊ณ
์นด๋๋ฅผ 2์ฅ ๋ฝ์ผ๋ผ๊ณ ํ ๋ฒ๋ง ์์ฒญํ ์ ์๊ฒ ๋ค์ ๐
kang-hyungu
left a comment
There was a problem hiding this comment.
์ ์ด์ฝฅ ๋ช ๊ฐ์ง ์ถ๊ฐ ํผ๋๋ฐฑ ๋จ๊ฒผ์ผ๋ ์ฐธ๊ณ ํ์ธ์
๊ถ๊ธํ ์ ์์ผ๋ฉด ์ง๋ฌธ์ฃผ์ธ์~
| import view.InputView; | ||
| import view.OutputView; | ||
|
|
||
| public class BlackjackControllerFactory { |
There was a problem hiding this comment.
ํฉํ ๋ฆฌ ํด๋์ค๋ฅผ ๋ฐ๋ก ๋ ์ด์ ๊ฐ ๋ญ์ฃ ?
| private final BlackjackGameManager blackjackGameManager; | ||
|
|
||
| public BlackjackController(InputView inputView, OutputView outputView, BlackjackGameManager blackjackGameManager) { | ||
| public BlackjackController(InputView inputView, OutputView outputView) { |
There was a problem hiding this comment.
์ ํด๋์ค๋ช ์ ์ปจํธ๋กค๋ฌ๋ผ ์ด๋ฆ ๋ถ์์ฃ ?
| } | ||
|
|
||
| private void addRepeatSix(List<Card> decks, Rank rank, Suit suit) { | ||
| private void addRepeatDeckCount(List<Card> decks, Rank rank, Suit suit) { |
There was a problem hiding this comment.
์ ํจ์๋ช ์ add๋ฅผ ๋ถ์ด์ จ๋์?
| } | ||
|
|
||
| public boolean isBlackjack() { | ||
| return calculateTotalScore() == BLACKJACK_SCORE && cards.size() == 2; |
There was a problem hiding this comment.
2๊ฐ ๋ฌด์์ ์๋ฏธํ๋์? ์์๋ก ์ถ์ถํด์ ์๋ฏธ ์๋ ์ด๋ฆ์ ๋ถ์ฌํ์ธ์
| import domain.participant.PlayerName; | ||
| import java.util.List; | ||
|
|
||
| public class BlackjackGameManagerFactory { |
There was a problem hiding this comment.
์ด ํด๋์ค๋ ์ ๋ง๋ ๊ฑด๊ฐ์?
|
|
||
| public final class BlackjackJudge { | ||
|
|
||
| public Result judgePlayerResult(Dealer dealer, Player player) { |
There was a problem hiding this comment.
if์ ์ด ๋๋ฌด ๋ง๊ณ ํจ์๊ฐ ๋๋ฌด ๊ธธ์ด ์ฝ๋ ํ์
ํ๊ธฐ๊ฐ ์ด๋ ต๋ค์
๋ค๋ฅธ ํ์๋ค๋ ์ด ์ฝ๋๋ฅผ ๋ณด๊ณ ๋ก์ง ํ์
ํ๊ธฐ๊ฐ ์ฝ์ง ์์ํ
๋ฐ์, ํจ์๊ฐ 10์ค ๋์ด๊ฐ์ง ์๋๋ก ๊ฐ์ ํด๋ณด์ธ์
| @@ -0,0 +1,19 @@ | |||
| package domain.game; | |||
|
|
|||
| public enum Result { | |||
|
|
||
| private final int betAmount; | ||
|
|
||
| public BetAmount(String betAmountInput) { |
There was a problem hiding this comment.
๋ณ์๋ช ์ input์ ๋ถ์ผ ํ์๊ฐ ์๋์?
| import java.util.List; | ||
| import java.util.function.Supplier; | ||
|
|
||
| public record Participants(Dealer dealer, Players players) { |
There was a problem hiding this comment.
ํด๋์ค๋ช
์ ์ฐธ์ฌ์๋ค์ธ๋ฐ ์ด๋ฆ๋ง ๋ด์๋ ๋ฌด์จ ์ผ์ ์ฒ๋ฆฌํ๋ ํด๋์ค์ธ์ง ํ์
์ด ์ด๋ ต๋ค์
๊ทธ๋ฆฌ๊ณ record๋ก ๋ง๋ ์ด์ ๋ ๋ญ๊ฐ์?
| import constant.Result; | ||
| import domain.participant.Player; | ||
|
|
||
| public record PlayerStatisticDto( |
There was a problem hiding this comment.
dto๊ฐ ๋ญ๊ฐ์? dto๊ฐ ํ์ํ๊ฐ์?
์ฒดํฌ ๋ฆฌ์คํธ
test๋ฅผ ์คํํ์ ๋, ๋ชจ๋ ํ ์คํธ๊ฐ ์ ์์ ์ผ๋ก ํต๊ณผํ๋์?์ด๋ค ๋ถ๋ถ์ ์ง์คํ์ฌ ๋ฆฌ๋ทฐํด์ผ ํ ๊น์?
์ฌ์ดํด1 ๋ง์ง๋ง ์ฝ๋ฉํธ์์ ๋ฐ์ํ ๋ด์ฉ
์ง๋ฌธ
์๋๋ ์ค๋ณต์ ๋ง๋ค๊ธฐ๋ ํ๋ค๋ ์ฌ์ค์ ์ถฉ๊ฒฉ์ ์ด๋ค์ ๐ฎ
"์ค๋ณต"์ ๋ํด 100% ๋ถ์ ์ ์ผ๋ก ๋ฐ๋ผ๋ดค์๋๋ฐ, ๊ทธ๋ ์ง ์์ ์๋ ์๋ค๋ ์ฌ์ค์ ์ธ์งํ๊ณ ์ ์ฐํ๊ฒ ์๊ฐํด๋ด์ผ๊ฒ ์ต๋๋ค!
ํ ๊ฐ์ง ๊ถ๊ธํ ์ ์ด ์๋๋ฐ, ์ฐฐ๋ฆฌ๋ constant ํจํค์ง๋ฅผ ์ฌ์ฉํ์๋ ํธ์ธ๊ฐ์?
๋ง์ฝ ์ฌ์ฉํ์ ๋ค๋ฉด ์ด๋ค ๊ฒฝ์ฐ์, ์ด๋ค ํด๋์ค๋ฅผ ๊ณตํต์ผ๋ก ๊ด๋ฆฌํ๋ constant ํจํค์ง๋ก ๋ถ๋ฆฌํ์๋์?
์ ๊ฐ ์๊ฐํ์ ๋ ํ์ฌ ์น๋ฌดํจ ํ๋จ์ ํ๋ ๋ฉ์๋๋ BlackjackGameManager ํด๋์ค์ getBlackjackStatistics ๋ฉ์๋ ๋ก์ง์ธ๋ฐ, ํนํ ํด๋น ๋ฉ์๋ ๋ด ์๋ 3์ค์ ๋ก์ง์ธ ๋ฏ ํฉ๋๋ค.
์ด ๋ก์ง์ ๊ฐ์ง๋ ๊ฐ์ฒด(A๋ผ๊ณ ์ง์นญํ๊ฒ ์ต๋๋ค)๋ฅผ ๋ฐ๋ก ๋ง๋ ๋ค๋ฉด A๋ judgePlayerResult ๋ฉ์๋์ calculatePlayerProfit ๋ฉ์๋๋ฅผ ํด๋์ค ๋ด์์ ๊ฐ์งํ ๋ฐ, ์ด๋ ๋ณด์๋ ๊ฒ์ฒ๋ผ ๋ฉ์๋์ ์ธ์๋ก Dealer์ Player๊ฐ ๋ค์ด๊ฐ๊ธฐ๋๋ฌธ์ A๊ฐ Dealer์ Player์๊ฒ ์์กดํ๊ฒ ๋๊ณ , ๊ฒฐํฉ๋๊ฐ ์ปค์ง๊ฒ ๋์ง ์์๊น๋ผ๋ ๋ถ๋ถ์ด ์ผ๋ ค๋ฉ๋๋ค. ๊ฒฐํฉ๋๊ฐ ์ปค์ง๋ฉด ์์ ๋ฒ์๊ฐ ์ปค์ง๊ฒ ๋๋ ๋จ์ ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์ด ๋ถ๋ถ์ ๋ํ ์ฐฐ๋ฆฌ์ ์๊ฒฌ์ด ๊ถ๊ธํฉ๋๋ค!
Rank ํด๋์ค์์ score์ ์์๊ฐ ํฌ์ฅ์ ๋ํด ๋ง์ํด์ฃผ์ จ๋๋ฐ, ๋จ์ํ ์์๋ฅผ ์ ์ฅํ๊ณ ์๊ณ ๋ธ๋์ญ ์ ์ ๊ท์น์ ๋ํ ๋ด์ฉ์ ๋ค๋ฅธ ๊ฐ์ฒด์์ ๋ฉ์๋๋ก ๊ตฌํํ๊ธฐ๋๋ฌธ์ score์์ ์ด๋ค ์ถ๊ฐ์ ์ธ ๊ท์น์ ๊ฒ์ฆํ๊ฑฐ๋ ๋ค๋ฃฐ์ง ์์ด๋์ด๊ฐ ๋ ์ค๋ฅด์ง ์๋ค์๐
ํน์ ์ฐฐ๋ฆฌ ์ ์ฅ์์ score๋ฅผ ์์๊ฐ ํฌ์ฅํ๋ค๋ฉด ์ด๋ค์์ผ๋ก ๊ตฌํํ์ค์ง ๊ถ๊ธํฉ๋๋ค!
1์ฐจ ํผ๋๋ฐฑ ์์ ์์
2์ฐจ ํผ๋๋ฐฑ ์์ ์์
3์ฐจ ํผ๋๋ฐฑ ์์ ์์