import java.util.LinkedList;

    // Maintain a collection of Card objects for a player.
    // Mostly a case of delegating to an underlying collection
    // and casting the result where required.
class Hand {
    public void add(Card c){
        if(c != null){
             getCards().add(c);
        }
    }

    public Card getNextCard(){
        return (Card) getCards().removeFirst();
    }

        // Add the given pile to the end of this one.
    public void addPile(Pile pile){
        getCards().addAll(pile.getCards());
    }

    public int numCards(){
        return getCards().size();
    }

    private LinkedList getCards(){
        return cards;
    }

    // Store the cards in a linked list, because we only need
    // access at either end.
    private final LinkedList cards = new LinkedList();
}

