-footer

garrettsmith.playingcards
Class StandardDeck

java.lang.Object
  extended by garrettsmith.playingcards.StandardDeck
All Implemented Interfaces:
Deck

public class StandardDeck
extends java.lang.Object
implements Deck

Represents a standard deck of 52 playing cards.

This class is not thread safe.

This deck contains 13 cards (two through ten, Jack, Queen, King, and Ace) in 4 suits (diamonds, hearts, spades, and clubs). It has no jokers.

Since:
Blackjack v1.0
Version:
Blackjack v1.0
Author:
Garrett Smith, gsmith at northwestern dot edu

Field Summary
static StandardDeck DECK
          Singleton instance of this immutable deck.
 
Method Summary
 java.util.List getAllCards()
          Returns a nonrandom list of all 52 cards contained in a fresh deck.
 int getNumCardsOfType(Card.Color color)
          Returns the number of cards in the deck whose color is equal to color.
 int getNumCardsOfType(Card.Suit suit)
          Returns the number of cards in the deck whose suit is equal to suite.
 int getNumCardsOfType(Card.Value value)
          Returns the number of cards in the deck whose value is equal to value.
 int size()
          Returns the number of cards in this deck: 52 for this specific deck.
 java.lang.String toString()
          Returns a string representation of this deck.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DECK

public static final StandardDeck DECK
Singleton instance of this immutable deck.

Method Detail

getAllCards

public java.util.List getAllCards()
Returns a nonrandom list of all 52 cards contained in a fresh deck.

Specified by:
getAllCards in interface Deck
Returns:
a nonrandom list of all 52 cards contained in a fresh deck.

size

public int size()
Returns the number of cards in this deck: 52 for this specific deck.

Specified by:
size in interface Deck
Returns:
the number of cards in this deck.

toString

public java.lang.String toString()
Returns a string representation of this deck.

Overrides:
toString in class java.lang.Object
Returns:
a string representing the deck

getNumCardsOfType

public int getNumCardsOfType(Card.Color color)
Returns the number of cards in the deck whose color is equal to color.

Specified by:
getNumCardsOfType in interface Deck

getNumCardsOfType

public int getNumCardsOfType(Card.Suit suit)
Returns the number of cards in the deck whose suit is equal to suite.

Specified by:
getNumCardsOfType in interface Deck

getNumCardsOfType

public int getNumCardsOfType(Card.Value value)
Returns the number of cards in the deck whose value is equal to value.

Specified by:
getNumCardsOfType in interface Deck

-footer

Copyright 2001-5 Garrett Smith. Use is subject to license terms.