-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathBlackJack.java
More file actions
59 lines (44 loc) · 1.3 KB
/
BlackJack.java
File metadata and controls
59 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package blackJack.domain;
import java.util.List;
public class BlackJack {
private static final int INITIAL_DRAW_CARD_COUNT = 2;
private final GameUser gameUser;
private final GameCard gameCard;
private BlackJack(List<String> userNames) {
this.gameUser = GameUser.from(userNames);
this.gameCard = GameCard.create();
cardShuffle();
}
public static BlackJack from(List<String> userNames) {
return new BlackJack(userNames);
}
private void cardShuffle() {
gameCard.shuffle();
}
public void initCardDraw() {
initDealerDraw();
initPlayerDraw();
}
private void initDealerDraw() {
gameUser.getDealer().appendToDeck(gameCard.drawCard(INITIAL_DRAW_CARD_COUNT));
}
private void initPlayerDraw() {
gameUser.getPlayers()
.forEach(player -> player.appendToDeck(gameCard.drawCard(INITIAL_DRAW_CARD_COUNT)));
}
public GameUser getGameUser() {
return gameUser;
}
public GameCard getGameCard() {
return gameCard;
}
public List<Player> getGamePlayers() {
return gameUser.getPlayers();
}
public Dealer getGameDealer() {
return gameUser.getDealer();
}
public Card drawGameCard() {
return gameCard.drawCard();
}
}