forked from next-step/java-blackjack-playground
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCards.java
More file actions
36 lines (29 loc) · 805 Bytes
/
Cards.java
File metadata and controls
36 lines (29 loc) · 805 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
package blackjack.domain.card;
import java.util.ArrayList;
import java.util.List;
public class Cards {
private final List<Card> cardList;
private int total;
public Cards() {
this.cardList = new ArrayList<>();
this.total = 0;
}
public String getAllCards() {
return cardList.toString();
}
public void getMoreCard(CardFactory cardFactory) throws Exception {
Card card = cardFactory.selectCard();
cardList.add(card);
Integer value = card.getNumber();
if(total < 11 && value==1){
total += 10; //handle if a number of card is 'A'
}
total += card.getNumber();
}
public int getTotal(){
return total;
}
public int getSize() {
return this.cardList.size();
}
}