ks.common.model
Class Deck

java.lang.Object
  extended byks.common.model.Element
      extended byks.common.model.Stack
          extended byks.common.model.Deck
Direct Known Subclasses:
MultiDeck

public class Deck
extends Stack

Models a deck of cards as a Stack.

Note: Cards are only removed from the top of the deck, but during the initialization routine, this subclass makes detailed use of the actual structure of cards within a stack.

When a Deck is created, it is initially empty. The proper way to create a deck is as follows:

 Deck d = new Deck ("personalName");
d.create (778726);
The create method will randomly shuffle the deck using a deterministic algorithm using 778726 as the seed for pseudo-random shuffling.

Creation date: (9/30/01 10:42:44 PM)


Constructor Summary
Deck()
          Construct an empty deck.
Deck(java.lang.String name)
          Construct an empty deck with the given name.
 
Method Summary
 void create(int seed)
          Create a deck using the prespecified shuffling algorithm based upon this seed value.
 void shuffle(int seed)
          Shuffle the deck using the given seed value as random seed.
 
Methods inherited from class ks.common.model.Stack
add, alternatingColors, alternatingColors, ascending, ascending, count, descending, descending, deselect, empty, get, getNumSelectedCards, getSelected, peek, peek, push, rank, removeAll, sameColor, sameColor, sameRank, sameRank, sameSuit, sameSuit, select, select, suit, toString
 
Methods inherited from class ks.common.model.Element
getListener, getName, setListener, setName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Deck

public Deck()
Construct an empty deck. The name of the deck is automatically generated.


Deck

public Deck(java.lang.String name)
Construct an empty deck with the given name.

If the name parameter passed in is null, then a generated name will be used.

Parameters:
name - String
Method Detail

create

public void create(int seed)
Create a deck using the prespecified shuffling algorithm based upon this seed value.

This method invokes the initialize method to properly construct the full deck before the shuffling algorithm commences. Note that this method makes detailed use of the internal structure of a Stack.

Creation date: (9/30/01 10:44:19 PM)

Parameters:
seed - int

shuffle

public void shuffle(int seed)
Shuffle the deck using the given seed value as random seed.

Parameters:
seed -