Class StandardDeck

java.lang.Object
  |
  +--StandardDeck

public class StandardDeck
extends Object

models a standard 52 card deck. Cards can be taken from the deck. The only way to add cards to the deck is by resetting the deck.
class invariants: -1 <= myTopCardIndex < MAX_CARDS


Field Summary
static int MAX_CARDS
           
 
Constructor Summary
StandardDeck()
          pre: none
post: deck created, with 52 cards,
 
Method Summary
 Card deal()
          A mutator that returns a value.
 boolean isEmpty()
          pre: none
post: returns true iff numCardsInDeck = 0
 int numCardsInDeck()
          pre: none;
post: returns number of cards left in logical deck
 void reset()
          pre: none post: deck reset to 52 cards and shuffled
 void shuffle()
          pre: none
post: deck shuffled.
 String toString()
          pre: none
post: return a String version of the Cards left in the deck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_CARDS

public static final int MAX_CARDS
See Also:
Constant Field Values
Constructor Detail

StandardDeck

public StandardDeck()
pre: none
post: deck created, with 52 cards,

Method Detail

deal

public Card deal()
A mutator that returns a value. Gack! pre: numCardsInDeck >= 1
post: top Card returned, new numCardsInDeck = old numCardsIndeck - 1


isEmpty

public boolean isEmpty()
pre: none
post: returns true iff numCardsInDeck = 0


numCardsInDeck

public int numCardsInDeck()
pre: none;
post: returns number of cards left in logical deck


reset

public void reset()
pre: none post: deck reset to 52 cards and shuffled


shuffle

public void shuffle()
pre: none
post: deck shuffled.


toString

public String toString()
pre: none
post: return a String version of the Cards left in the deck

Overrides:
toString in class Object


Generated by BlueJ