-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathDealer.java
More file actions
39 lines (29 loc) · 867 Bytes
/
Dealer.java
File metadata and controls
39 lines (29 loc) · 867 Bytes
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
package blackjack.domain;
public class Dealer extends Player {
private static final int SCORE_THRESHOLD = 16;
private static final String DEALER = "딜러";
private static final int TWICE = 2;
private final Deck deck;
public Dealer() {
super(DEALER);
this.deck = new Deck();
}
public void allocateInitialCards(Player player) {
for (int i = 0; i < TWICE; i++) {
Card popped = deck.popCard();
player.receiveCard(popped);
}
}
public void allocateCard(Player player) {
Card popped = deck.popCard();
player.receiveCard(popped);
}
public boolean addOneMoreCard() {
int score = calculateScore();
if (score <= SCORE_THRESHOLD) {
cards.add(deck.popCard());
return true;
}
return false;
}
}