Class Deck

java.lang.Object
  |
  +--Deck

public class Deck
extends java.lang.Object

Represents a deck of playing cards. In order to have maximum flexibility, this class does not implement a standard deck of playing cards; it only provides the functionality of a deck of cards. The client programmer must instantiate a Deck object, then populate it with the set of playing cards appropriate for the card game being implemented. This allows for proper implementation of card games such as pinochle (a 48-card deck containing only aces, nines, tens, jacks, queens, and kings in all four suits, with each card present twice in the deck) or casino-style blackjack (where six standard decks are used for a game).

Version:
1.0
Author:
John K. Estell

Constructor Summary
Deck()
          Creates an empty deck of cards.
 
Method Summary
 void addCard(Card card)
          Adds a card to the deck.
 Card dealCard()
          Deal one card from the deck.
 int getNumberOfCardsRemaining()
          The number of cards left in the deck.
 int getSizeOfDeck()
          The size of a deck of cards.
 boolean isEmpty()
          Looks for an empty deck.
 void restoreDeck()
          Restores the deck to "full deck" status.
 void shuffle()
          Shuffles the cards present in the deck.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Deck

public Deck()
Creates an empty deck of cards.
Method Detail

addCard

public void addCard(Card card)
Adds a card to the deck.
Parameters:
card - card to be added to the deck.

getSizeOfDeck

public int getSizeOfDeck()
The size of a deck of cards.
Returns:
the number of cards present in the full deck.

getNumberOfCardsRemaining

public int getNumberOfCardsRemaining()
The number of cards left in the deck.
Returns:
the number of cards left to be dealt from the deck.

dealCard

public Card dealCard()
Deal one card from the deck.
Returns:
a card from the deck, or the null reference if there are no cards left in the deck.

shuffle

public void shuffle()
Shuffles the cards present in the deck.

isEmpty

public boolean isEmpty()
Looks for an empty deck.
Returns:
true if there are no cards left to be dealt from the deck.

restoreDeck

public void restoreDeck()
Restores the deck to "full deck" status.