//************************************************************ // // Deck.Java Authors: Lewis, Chase, Coleman // // Provides an implementation of a deck of cards using a // set to represent the cards // //************************************************************ import java.util.Random; import javax.swing.*; import java.awt.*; import java.util.*; public class Deck { ArrayList myDeck = new ArrayList(); /********************************************************** Constructs a deck of 52 Cards and puts them in the set. **********************************************************/ public Deck() { String [] suits = {"spade", "heart", "diamond", "club"}; char [] suitChar = {'s', 'h', 'd', 'c'}; int [] values = {2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11}; String [] faces = {"Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace"}; for(int suit = 0; suit < suits.length; suit++) { for (int card = 2; card <= 14; card++) { String fileName = "resources/" + card + suitChar[suit] + ".gif"; Card c = new Card(new ImageIcon(fileName), values[card-2], suits[suit], faces[card-2]); myDeck.add(c); } } shuffle(); } /** * Deals a card from this deck. * @return the card just dealt, or null if all the cards have been * previously dealt. */ public Card getCard() { // TO DO /** * Determines if this deck is empty (no undealt cards). * @return true if this deck is empty, false otherwise. */ public boolean isEmpty() { // TO DO } // Shuffle the Cards in this deck public void shuffle() { // TO DO } // Returns the String representation of the // entire Deck of Cards. Each Card should be // on a new line. To make a new line between each Card, // append the escape sequence "\n" public String toString() { // TO DO } }//end deck