-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShoe.java
More file actions
84 lines (80 loc) · 2.19 KB
/
Shoe.java
File metadata and controls
84 lines (80 loc) · 2.19 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.ArrayList;
import java.util.Collections;
/**
* Shoe.java
*
* @author: Zachary, Anand, Jason (Group 7)
* Assignment #: Blackjack Project
*
* Brief Program Description:
*
*
*/
public class Shoe
{
/**
* A shoe consists of an ArrayList of Cards
*/
private ArrayList<Card> shoe = new ArrayList<Card>();
private final int DECK_NUMBER;
/**
* @param int numDecks the number of decks to be shuffled in the shoe
* Adds every card in each deck to the shoe and then shuffles the shoe
*/
public Shoe(int numDecks)
{
DECK_NUMBER = numDecks;
for(int i=0; i<numDecks; i++)
{
Deck deck = new Deck();
for(Card c: deck.getDeck())
{
shoe.add(c); //adds every card from each deck to the shoe
}
}
Collections.shuffle(shoe); //shuffles the arraylist
}
/**
* @param none
* @return the card at the top of the shoe
*/
public Card drawCard()
{
if(shoe.size() == 0) //checks if shoe is empty. If so, refills the shoe
{
shoe = new ArrayList<Card>();
for(int i=0; i<DECK_NUMBER; i++)
{
Deck deck = new Deck();
for(Card c: deck.getDeck())
{
shoe.add(c); //adds every card from each deck to the shoe
}
}
Collections.shuffle(shoe); //shuffles the arraylist
}
return shoe.remove(0); //draws from top of deck
}
/**
* @param none
* @return a String printing out information about every card in the shoe
* in addition to the number of cards in the shoe
*/
public String toString()
{
String values = "";
for(Card card: shoe)
{
values = values + card.toString() +"\n";
}
return values+"\n"+shoe.size()+" cards in shoe";
}
/**
* @param none
* @return an ArrayList of Cards which is the instance variable of this class
*/
public ArrayList<Card> getShoe()
{
return shoe;
}
}