-
Notifications
You must be signed in to change notification settings - Fork 313
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
๐ 4๋จ๊ณ - ๋ธ๋์ญ(๋ฒ ํ ) #827
base: sjjeong
Are you sure you want to change the base?
Changes from all commits
165ad5a
a5954de
129b572
6f81637
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,5 @@ | ||
package blackjack.domain | ||
|
||
object Const { | ||
const val NUMBER_BLACKJACK = 21 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,21 @@ package blackjack.domain | |
data class Participant( | ||
override val name: String | ||
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.
|
||
) : Player(name = name) { | ||
var bettingMoney: Int = 0 | ||
|
||
override val canReceiveCard: Boolean | ||
get() { | ||
return score <= CAN_RECEIVE_CARD_SCORE | ||
} | ||
|
||
override fun setupCard(blackjackShoe: BlackjackShoe) { | ||
repeat(NUMBER_OF_INIT_CARD) { | ||
receiveCard(blackjackShoe.draw()) | ||
} | ||
} | ||
|
||
companion object { | ||
private const val CAN_RECEIVE_CARD_SCORE = 21 | ||
private const val NUMBER_OF_INIT_CARD = 2 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package blackjack.domain | ||
|
||
class Participants(private val participants: List<Participant>): List<Participant> by participants { | ||
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.
ํ์ฌ ๊ฐ๋ณ๊ฒ ์ฝ๋ฉํธ๋ก ๋จ๊ฒจ์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์. ๐ |
||
|
||
constructor(vararg participantNames: String): this(participantNames.map { name -> Participant(name.trim()) }) | ||
|
||
fun setupCard(blackjackShoe: BlackjackShoe) { | ||
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.
์ฐธ๊ฐ์์ ์
์ฅ์์ ์ฐธ๊ฐ์. |
||
participants.forEach { participant -> participant.setupCard(blackjackShoe) } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ abstract class Player( | |
return score | ||
} | ||
|
||
var money: Int = 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. ๊ผญ ์์๊ฐ ์ ํด์ ธ์๋ ๊ฒ์ ์๋์ง๋ง, ๊ฐ์ธ์ ์ธ ์๊ฐ์ผ๋ก๋ ์ฝ๊ธฐ์ ์ฉ ํ๋กํผํฐ๋ณด๋ค๋ ์ค์ |
||
|
||
abstract fun setupCard(blackjackShoe: BlackjackShoe) | ||
|
||
fun receiveCard(card: Card) { | ||
_cardList.add(card) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package blackjack.view | ||
|
||
import blackjack.domain.Participant | ||
import blackjack.domain.Participants | ||
|
||
class InputView { | ||
|
||
|
@@ -19,4 +20,13 @@ class InputView { | |
} | ||
} | ||
|
||
fun requestBettingMoney(participants: Participants) { | ||
println() | ||
participants.forEach { participant -> | ||
println("${participant.name}์ ๋ฐฐํ ๊ธ์ก์?") | ||
val bettingMoney = readlnOrNull()?.toIntOrNull() ?: error("๋ฐฐํ ์ ") | ||
participant.bettingMoney = bettingMoney | ||
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. Participant๊ฐ 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. Participant ๊ฐ์ฒด์๊ฒ ๋ฒ ํ ์ํ๋ผ๊ณ ๋ฉ์์ง๋ฅผ ๋ณด๋ด๋ณด๋ฉด ์ด๋จ๊น์? ๐ |
||
} | ||
} | ||
|
||
} |
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.
ready()
๋play()
์ ๊ฒฝ์ฐ dealer๏ฟฝ, participants๋ฅผ ํ๋กํผํฐ๋ก ๊ฐ์งBlackjackGame
๊ฐ์ฒด์๊ฒ ์ญํ ์ ์์ํด๋ณผ ์๋ ์์ ๊ฒ ๊ฐ์์. ๐๋ฌผ๋ก ์ค๊ฐ์ ์ ๋ ฅ๋ฐ๋ ๋ถ๋ถ๋ค์ด ์์ด์, ์กฐ๊ธ ์ด๋ ต๊ฒ ๋๊ปด์ง์ค ์๋ ์์ ๊ฒ ๊ฐ๋ค์.
์ด ๋ฐฉํฅ์ผ๋ก ํ๋ฒ ๊ณ ๋ฏผํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์์!