Deck of Cards

Structure

public enum Suit {
    CLUBS(1), SPADES(2), HEARTS(3), DIAMONDS(4);
    int value;

    private Suit(int v) {
        value = v;
    }
}

public class Card {

    private int card;
    private Suit suit;

    public Card(int r, Suit s) {
        card = r;
        suit = s;
    }

    public int value() {
        return card;
    }

    public Suit suit() {
        return suit;
    }
}

public class BlackJackCard extends Card {
    public BlackJackCard(int r, Suit s) {
        super(r, s);
    }

    @Override
    public int value() {
        int r = super.value();
        if (r == 1)
            return 11; // aces are 11
        if (r < 10)
            return r;
        return 10;
    }

    boolean isAce() {
        return super.value() == 1;
    }
}

class deck{ 
     /**
      * Constructor.  Create an unshuffled deck of cards.
      */
     public Deck()

     /**
      * Put all the used cards back into the deck,
      * and shuffle it into a random order.
      */
     public void shuffle()

     /**
      * As cards are dealt from the deck, the number of 
      * cards left decreases.  This function returns the 
      * number of cards that are still left in the deck.
      */
     public int cardsLeft()

     /**
      * Deals one card from the deck and returns it.
      * @throws IllegalStateException if no more cards are left.
      */
     public Card dealCard()
} 


class hand {
    /**
     * Constructor. Create a Hand object that is initially empty.
     */
    public Hand()

    /**
     * Discard all cards from the hand, making the hand empty.
     */
    public void clear()

    /**
     * Add the card c to the hand.  c should be non-null.
     * @throws NullPointerException if c is null.
     */
    public void addCard(Card c)

    /**
     * If the specified card is in the hand, it is removed.
     */
    public void removeCard(Card c)

    /**
     * Remove the card in the specified position from the
     * hand.  Cards are numbered counting from zero.
     * @throws IllegalArgumentException if the specified 
     *    position does not exist in the hand.
     */
    public void removeCard(int position)

    /**
     * Return the number of cards in the hand.
     */
    public int getCardCount()

    /**
     * Get the card from the hand in given position, where 
     * positions are numbered starting from 0.
     * @throws IllegalArgumentException if the specified 
     *    position does not exist in the hand.
     */
    public Card getCard(int position)

    /**
     * Sorts the cards in the hand so that cards of the same 
     * suit are grouped together, and within a suit the cards 
     * are sorted by value.
     */
    public void sortBySuit()

    /**
     * Sorts the cards in the hand so that cards are sorted into
     * order of increasing value.  Cards with the same value 
     * are sorted by suit. Note that aces are considered
     * to have the lowest value.
     */
    public void sortByValue()
}

Reference

Programming Example: Card, Hand, Deck