com.blackledge.david.game.solitaire
Class Card

java.lang.Object
  extended by com.blackledge.david.game.solitaire.Card

public class Card
extends Object

Represents a Playing Card

Version:
$Revision: 1.1 $

Field Summary
static int ACE
          Constant for a Card Value as returned by getValue() - the Ace is valued as 1 here.
static int BLACK
          Constant for a suit color as returned by getSuitColor()
static int CLUB
          Constant for a suit as returned by getSuit()
static int DIAMOND
          Constant for a suit as returned by getSuit()
static int HEART
          Constant for a suit as returned by getSuit()
static int JACK
          Constant for a Card Value as returned by getValue()
static int KING
          Constant for a Card Value as returned by getValue()
static int QUEEN
          Constant for a Card Value as returned by getValue()
static int RED
          Constant for a suit color as returned by getSuitColor()
static int SPADE
          Constant for a suit as returned by getSuit()
 
Constructor Summary
Card(int suit, int value, boolean faceUp)
          Create a card with the given suit, value, and face-up state.
 
Method Summary
 boolean equals(Object obj)
          Check if two cards are equal (same suit, same value - ignores faceUp)
static int getMaxValue()
          The maximum valid value for a card
static int getMinValue()
          The minimum valid value for a card
 int getSuit()
           
 int getSuitColor()
           
 int getValue()
           
 String getValueString()
          1==A, 11==J, 12==Q, 13==K, all others are integers in string form.
 int hashCode()
          have to implement so hashmap works right.
 boolean isFaceUp()
          Report whether this card is currently face up.
 void setFaceUp(boolean faceUp)
          Set whether this card is currently face up.
 String toString()
           
 boolean turnOver()
          Turns this card over.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HEART

public static final int HEART
Constant for a suit as returned by getSuit()

See Also:
Constant Field Values

CLUB

public static final int CLUB
Constant for a suit as returned by getSuit()

See Also:
Constant Field Values

DIAMOND

public static final int DIAMOND
Constant for a suit as returned by getSuit()

See Also:
Constant Field Values

SPADE

public static final int SPADE
Constant for a suit as returned by getSuit()

See Also:
Constant Field Values

RED

public static final int RED
Constant for a suit color as returned by getSuitColor()

See Also:
Constant Field Values

BLACK

public static final int BLACK
Constant for a suit color as returned by getSuitColor()

See Also:
Constant Field Values

KING

public static final int KING
Constant for a Card Value as returned by getValue()

See Also:
Constant Field Values

QUEEN

public static final int QUEEN
Constant for a Card Value as returned by getValue()

See Also:
Constant Field Values

JACK

public static final int JACK
Constant for a Card Value as returned by getValue()

See Also:
Constant Field Values

ACE

public static final int ACE
Constant for a Card Value as returned by getValue() - the Ace is valued as 1 here.

See Also:
Constant Field Values
Constructor Detail

Card

public Card(int suit,
            int value,
            boolean faceUp)
Create a card with the given suit, value, and face-up state.

Parameters:
suit -
value -
Method Detail

toString

public String toString()
Overrides:
toString in class Object
Returns:
a 2-5 character representation of the card such as "2H" for the 2 of hearts, or "(10S)" for the 10 of spades, but face down.

equals

public boolean equals(Object obj)
Check if two cards are equal (same suit, same value - ignores faceUp)

Overrides:
equals in class Object

hashCode

public int hashCode()
have to implement so hashmap works right. uses same stuff minimum information as equals, combined into string, and gets the hashcode of that string.

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

getMinValue

public static int getMinValue()
The minimum valid value for a card

Returns:
1

getMaxValue

public static int getMaxValue()
The maximum valid value for a card

Returns:
13

getSuit

public int getSuit()
Returns:
The Suit as an integer Code

getValue

public int getValue()
Returns:
the integer value of this card.

getValueString

public String getValueString()
1==A, 11==J, 12==Q, 13==K, all others are integers in string form.

Returns:
the value of this card as a String.

getSuitColor

public int getSuitColor()
Returns:
the Suit's color as an integer Code

isFaceUp

public boolean isFaceUp()
Report whether this card is currently face up.

Returns:

setFaceUp

public void setFaceUp(boolean faceUp)
Set whether this card is currently face up.

Parameters:
faceUp -

turnOver

public boolean turnOver()
Turns this card over.

Returns:
the resulting FaceUp state (true if Face Up, false if not).