Class CardPile

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<Card>
                  extended by CardPile
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Card>, java.util.Collection<Card>, java.util.Deque<Card>, java.util.List<Card>, java.util.Queue<Card>

public class CardPile
extends java.util.LinkedList<Card>

This class stores a collection of playing cards in a linked list format.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CardPile(Card[] cards, int x, int y)
          Constructor puts array of cards into pile
CardPile(CardPile pile)
          Copy constructor
CardPile(int x, int y)
          Constructor initializes location of empty pile
 
Method Summary
 void append(CardPile suffix)
          Appends the provided suffix onto this list.
 void draw(java.awt.Graphics g)
          Draws the pile at its location on the table.
 int getX()
          Accessor for x coordinate of pile
 int getY()
          Accessor for y coordinate of pile
 void insertAfter(Card card, Card mark)
          Insert a card node after the specified marker
 void insertAfter(CardPile insert, Card mark)
          Inserts a one pile into another, leaving the inserted pile empty
 void insertBefore(Card card, Card mark)
          Insert a card node before the specified marker
 void insertBefore(CardPile insert, Card mark)
          Inserts a one pile into another, leaving the inserted pile empty
 java.util.ListIterator<Card> iteratorAfter(Card mark)
          Find an iterator just after the mark
 java.util.ListIterator<Card> iteratorBefore(Card mark)
          Find an iterator just before the mark
 Card locateCard(int x, int y)
          Determine if the specified click falls upon a card in this pile.
 void print()
          Prints a representation of a CardPile
 void setX(int x)
          Manipulator for x coordinate of pile
 void setY(int y)
          Manipulator for y coordinate of pile
 CardPile split(Card mark)
          Moves every element after the mark into a new pile.
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 
Methods inherited from interface java.util.Deque
iterator
 

Constructor Detail

CardPile

public CardPile(int x,
                int y)
Constructor initializes location of empty pile


CardPile

public CardPile(CardPile pile)
Copy constructor


CardPile

public CardPile(Card[] cards,
                int x,
                int y)
Constructor puts array of cards into pile

Method Detail

getX

public int getX()
Accessor for x coordinate of pile


getY

public int getY()
Accessor for y coordinate of pile


setX

public void setX(int x)
Manipulator for x coordinate of pile


setY

public void setY(int y)
Manipulator for y coordinate of pile


iteratorBefore

public java.util.ListIterator<Card> iteratorBefore(Card mark)
Find an iterator just before the mark

Parameters:
mark - New card goes before this one

iteratorAfter

public java.util.ListIterator<Card> iteratorAfter(Card mark)
Find an iterator just after the mark

Parameters:
mark - New card goes before this one

insertBefore

public void insertBefore(Card card,
                         Card mark)
Insert a card node before the specified marker

Parameters:
node - The card to insert
mark - New card goes before this one

insertAfter

public void insertAfter(Card card,
                        Card mark)
Insert a card node after the specified marker

Parameters:
card - The card to insert
mark - New card goes after this one

insertBefore

public void insertBefore(CardPile insert,
                         Card mark)
Inserts a one pile into another, leaving the inserted pile empty

Parameters:
insert - list to insert
mark - insert before this card

insertAfter

public void insertAfter(CardPile insert,
                        Card mark)
Inserts a one pile into another, leaving the inserted pile empty

Parameters:
insert - list to insert
mark - insert after this point

split

public CardPile split(Card mark)
Moves every element after the mark into a new pile. If mark is null, entire pile is moved. The location of the new pile will be (0,0).

Parameters:
mark - elements including and after this are moved
Returns:
the suffix pile

append

public void append(CardPile suffix)
Appends the provided suffix onto this list. If the suffix list is empty, nothing happens. If this list is empty, the suffix list takes its place.

Parameters:
suffix - list to append and empty

draw

public void draw(java.awt.Graphics g)
Draws the pile at its location on the table.

Parameters:
g - Graphics object to draw into

locateCard

public Card locateCard(int x,
                       int y)
Determine if the specified click falls upon a card in this pile. If so, return the node holding that card.

Parameters:
x - Coordinate of mouse click
y - Coordinate of mouse click
Returns:
Card holding clicked card

print

public void print()
Prints a representation of a CardPile