Page 342 - AP Computer Science A, 7th edition
P. 342
} }
}
Here is a simple driver class that tests the Deck class:
public class DeckMain {
public static void main(String args[]) {
Deck d = new Deck(); d.shuffle(); d.writeDeck();
} }
NOTE
There is no evidence of the array that holds the deck of cards —deck is a private instance variable and is therefore invisible to clients of the Deck class.
Array of Class Objects
Suppose a large card tournament needs to keep track of many decks. The code to do this could be implemented with an array of Deck:
public class ManyDecks {
private Deck[] allDecks;
public static final int NUMDECKS = 500;
/∗ ∗ constructor ∗ / public ManyDecks() {
allDecks = new Deck[NUMDECKS];
for (int i = 0; i < NUMDECKS; i++)
allDecks[i] = new Deck();
}