File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
src/main/kotlin/blackJack Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ package blackJack
2
+
3
+ import blackJack.controller.BlackJackController
4
+
5
+ class BlackJackRunner
6
+
7
+ fun main () {
8
+ BlackJackController ().play()
9
+ }
Original file line number Diff line number Diff line change
1
+ package blackJack.controller
2
+
3
+ import blackJack.model.Dealer
4
+ import blackJack.model.Player
5
+ import blackJack.view.InputView
6
+ import blackJack.view.OutputView
7
+
8
+ class BlackJackController {
9
+ fun play () {
10
+ val req = InputView .getNames()
11
+
12
+ val candidates = req.map { Player (it) }
13
+ val dealer = Dealer (" dealer" )
14
+
15
+ val players = dealer.startGame(candidates)
16
+ OutputView .printPlayersState(players)
17
+
18
+ players.forEach { player ->
19
+ shouldContinue(player, dealer)
20
+ }
21
+
22
+ OutputView .printFinalState(players)
23
+ }
24
+
25
+ private fun shouldContinue (player : Player , dealer : Dealer ) {
26
+ while (true ) {
27
+ val req = InputView .getPlayerInput(player.name)
28
+ if (req == " n" ) {
29
+ break
30
+ }
31
+ player.askMoreCard(dealer)
32
+
33
+ if (dealer.isDrawCardAllowedFor(player).not ()) {
34
+ break
35
+ }
36
+ OutputView .printPlayerState(player)
37
+ }
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments