Class Deck

java.lang.Object
  extended by Deck

public class Deck
extends java.lang.Object

Represents a deck of cards. A deck starts with 52 cards. A deck may be shuffled (i.e. randomly mix up the order of the cards in the deck). The cards in a deck may be dealt one by one from the deck. Bugs: none known


Field Summary
static int DECK_SIZE
           
 
Constructor Summary
Deck()
          Constructs a new Deck object containing 52 cards.
 
Method Summary
 Card deal()
          Deals one card from the deck, decreasing the number of cards in the deck by one.
 void reset()
          Resets the deck so that it has all its cards.
 void shuffle()
          Shuffles the deck (i.e.
 java.lang.String toString()
          Returns a String representation of the Deck object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DECK_SIZE

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

Deck

public Deck()
Constructs a new Deck object containing 52 cards.

Method Detail

deal

public Card deal()
Deals one card from the deck, decreasing the number of cards in the deck by one.

Returns:
the next Card object in the deck; null if deck is empty

shuffle

public void shuffle()
Shuffles the deck (i.e. randomly reorders the cards in the deck).


reset

public void reset()
Resets the deck so that it has all its cards. Note that the order of the cards may be random.


toString

public java.lang.String toString()
Returns a String representation of the Deck object. The cards currently in the deck are printed out 13 to a row.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the deck