-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathCardPack.java
More file actions
33 lines (26 loc) · 841 Bytes
/
CardPack.java
File metadata and controls
33 lines (26 loc) · 841 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
package blackjack.domain.card;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class CardPack {
private final List<Card> cardPack;
public CardPack(List<Card> cardPack) {
this.cardPack = cardPack;
}
public static CardPack createWithShuffling() {
final List<Card> cards = new ArrayList<>();
for (final CardSymbol symbol : CardSymbol.values()) {
Arrays.stream(CardType.values())
.forEach(type -> cards.add(new Card(symbol, type)));
}
Collections.shuffle(cards);
return new CardPack(new ArrayList<>(cards));
}
public List<Card> getCardPack() {
return Collections.unmodifiableList(cardPack);
}
public Card pick() {
return cardPack.remove(0);
}
}