-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeck.java
48 lines (43 loc) · 941 Bytes
/
Deck.java
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
import java.util.ArrayList;
import java.util.Collections;
public class Deck //Just for Saat Aath!
{
private ArrayList<Card> cardList;
public Deck()
{
cardList = new ArrayList<Card>();
for (int i = 8; i <= 14; i++)
{
cardList.add(new Card(Card.SPADES, i));
cardList.add(new Card(Card.HEARTS, i));
cardList.add(new Card(Card.DIAMONDS, i));
cardList.add(new Card(Card.CLUBS, i));
}
cardList.add(new Card(Card.SPADES, 7));
cardList.add(new Card(Card.HEARTS, 7));
}
public String toString()
{
String deckString = "";
for (Card c : cardList)
{
deckString += c.toString() + "\n";
}
return deckString;
}
public void shuffle()
{
Collections.shuffle(cardList);
}
//care : this mutates the deck
public Card[] deal(int numCards)
{
shuffle();
Card[] dealtCards = new Card[numCards];
for (int i = 0; i < numCards; i++)
{
dealtCards[i] = cardList.remove(0);
}
return dealtCards;
}
}