org.vizzini.game.cardgame
Class CardCollection

java.lang.Object
  extended by org.vizzini.util.AbstractCollection
      extended by org.vizzini.util.AbstractMap
          extended by org.vizzini.game.TokenCollection
              extended by org.vizzini.game.cardgame.CardCollection
All Implemented Interfaces:
PropertyChangeListener, Serializable, Cloneable, Iterable, Collection, EventListener, ICardCollection, ITokenCollection, ICollection
Direct Known Subclasses:
PokerDeck

public class CardCollection
extends TokenCollection
implements ICardCollection

Provides a card collection. This collection can be used for a full deck, a discard pile, or an agent's hand.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Constructor Summary
CardCollection()
           
 
Method Summary
 ICard get(int index)
          Return the card at the given index.
 ICard get(String name, ISuit suit)
          Return the card with the given name and suit.
 ICard getFirst()
          Return the first card.
 Collection getFlushes(int minimumCount)
          Return a collection of CardCollection s of flushes.
protected  Object getKey(Object object)
          Return the card key.
protected  Object getKey(String name, ISuit suit)
          Return the card key.
 Collection getKinds(int minimumCount)
          Return a collection of CardCollection s of kinds.
 ICard getLast()
          Return the last card.
 Collection getStraights(int minimumCount)
          Return a collection of CardCollection s of straights.
protected  Class getType()
          Return the type this collection holds.
 void propertyChange(PropertyChangeEvent event)
          Implement a property change listener for relevant token properties.
 ICard removeFirst()
          Remove and return the first card.
 ICard removeLast()
          Remove and return the last card.
 void shuffle()
          Randomly reorder the cards.
 void sort()
          Sort the cards.
 
Methods inherited from class org.vizzini.game.TokenCollection
add, clone, configure, configure, findByName, get, get, getData, getKey, getTokenPropertyNames, iterator, remove
 
Methods inherited from class org.vizzini.util.AbstractMap
clear, contains, equals, hashCode, isEmpty, iterator, size, toString
 
Methods inherited from class org.vizzini.util.AbstractCollection
addAll, containsAll, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.game.ITokenCollection
clone, configure, findByName, get, get, iterator
 
Methods inherited from interface org.vizzini.util.ICollection
toString
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

CardCollection

public CardCollection()
Method Detail

get

public ICard get(int index)
Return the card at the given index.

Specified by:
get in interface ICardCollection
Since:
v0.1

get

public ICard get(String name,
                 ISuit suit)
Return the card with the given name and suit.

Since:
v0.1

getFirst

public ICard getFirst()
Return the first card.

Specified by:
getFirst in interface ICardCollection
Since:
v0.1

getFlushes

public Collection getFlushes(int minimumCount)
Return a collection of CardCollection s of flushes. Each collection will contain at least the given minimum number of cards.

Parameters:
minimumCount - Minimum number of cards required to be considered a kind.
Since:
v0.1

getKinds

public Collection getKinds(int minimumCount)
Return a collection of CardCollection s of kinds. Each collection will contain at least the given minimum number of cards.

Specified by:
getKinds in interface ICardCollection
Parameters:
minimumCount - Minimum number of cards required to be considered a kind.
Since:
v0.1

getLast

public ICard getLast()
Return the last card.

Specified by:
getLast in interface ICardCollection
Since:
v0.1

getStraights

public Collection getStraights(int minimumCount)
Return a collection of CardCollection s of straights. Each collection will contain at least the given minimum number of cards.

Specified by:
getStraights in interface ICardCollection
Parameters:
minimumCount - Minimum number of cards required to be considered a kind.
Since:
v0.1

propertyChange

public void propertyChange(PropertyChangeEvent event)
Implement a property change listener for relevant token properties.

Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class TokenCollection
Since:
v0.2

removeFirst

public ICard removeFirst()
Remove and return the first card.

Specified by:
removeFirst in interface ICardCollection
Since:
v0.1

removeLast

public ICard removeLast()
Remove and return the last card.

Specified by:
removeLast in interface ICardCollection
Since:
v0.1

shuffle

public void shuffle()
Randomly reorder the cards.

Specified by:
shuffle in interface ICardCollection
Since:
v0.1

sort

public void sort()
Sort the cards.

Specified by:
sort in interface ICardCollection
Since:
v0.1

getKey

protected Object getKey(Object object)
Return the card key.

Overrides:
getKey in class TokenCollection
Since:
v0.1

getKey

protected Object getKey(String name,
                        ISuit suit)
Return the card key.

Since:
v0.1

getType

protected Class getType()
Return the type this collection holds.

Overrides:
getType in class TokenCollection
Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02