import java.util.LinkedList;

    // Maintain a pile of cards for a single round in the game.
    // At the end of the round, the pile is given to the winner
    // of the round.
class Pile {
    // Do the top two cards match?
    public boolean snap(){
        int howMany = numCards();
        if(howMany < 2){
            return false;
        }
        else{
            LinkedList pile = getCards();
            Card top = (Card) pile.getLast();
            Card previous = (Card) pile.get(howMany-2);

            // See if the values are the same.
            return top.getValue() == previous.getValue();
        }
    }

       // Add a card to the end of the pile.
    public void addCard(Card c){
        getCards().add(c);
    }

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


       // A Player needs access to the cards when they are won.
    public LinkedList getCards(){
        return cards; 
    }

    private LinkedList cards = new LinkedList();
}
