-footer

garrettsmith.playingcards
Class Card

java.lang.Object
  extended by garrettsmith.playingcards.Card

public final class Card
extends java.lang.Object

Represents a card in a typical deck of playing cards. Card is immutable, and, therefore, thread safe.

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

Nested Class Summary
static class Card.Color
          Represents the card's color: red, black, or none.
static class Card.Suit
          Represents a card's suit, such as spades or clubs.
static class Card.Value
          Represents a card's value: two, queen, or ace, for example.
 
Constructor Summary
Card()
          Creates a joker.
Card(Card.Value value, Card.Suit suit)
           Creates a new card with the specified suit and value.
 
Method Summary
 boolean equals(java.lang.Object object)
          Returns whether the object referred to in the object parameter is equal to this instance.
 Card.Color getColor()
          Returns a string representation of this card's color.
 Card.Suit getSuit()
          Returns the card's suit.
 Card.Value getValue()
          Returns the card's value.
 int hashCode()
          Returns a hash value for this card.
 java.lang.String toString()
          Returns a string representation this card's state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Card

public Card()
Creates a joker.


Card

public Card(Card.Value value,
            Card.Suit suit)

Creates a new card with the specified suit and value.

Parameters:
suit - the card's suit, for example, hearts
value - the card's value, for example, a ten
Method Detail

equals

public boolean equals(java.lang.Object object)
Returns whether the object referred to in the object parameter is equal to this instance.

Overrides:
equals in class java.lang.Object
Returns:
whether the two cards are the same.

getColor

public Card.Color getColor()
Returns a string representation of this card's color.

Returns:
a representation of this card's color.

getSuit

public Card.Suit getSuit()
Returns the card's suit.

Returns:
the card's suit.

getValue

public Card.Value getValue()
Returns the card's value.

Returns:
the card's value.

hashCode

public int hashCode()
Returns a hash value for this card.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash value for this object.

toString

public java.lang.String toString()
Returns a string representation this card's state.

Overrides:
toString in class java.lang.Object
Returns:
representing this card's state.

-footer

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