org.jogre.common.games
Class Card

java.lang.Object
  extended byorg.jogre.common.comm.CommGameMessage
      extended byorg.jogre.common.comm.CommTableMessage
          extended byorg.jogre.common.games.Card
All Implemented Interfaces:
Comparable, ITransmittable

public class Card
extends CommTableMessage
implements Comparable

Card defines a generic playing card that is transmittable

Version:
Alpha 0.2.3
Author:
Garrett Lehman

Field Summary
static String ACE
           
static int CARD_PIXEL_HEIGHT
           
static int CARD_PIXEL_WIDTH
           
static int CARD_SPACING
           
static Image cardImages
           
static int[] cardIntOrderValues
           
static int[] cardIntValues
           
static String[] cardStringValues
           
static char CLUB
           
static char DIAMOND
           
static String EIGHT
           
static String FIVE
           
static String FOUR
           
static char HEART
           
static String JACK
           
static String KING
           
static String NINE
           
static String QUEEN
           
static String SEVEN
           
static String SIX
           
static char SPADE
           
static String TEN
           
static String THREE
           
static String TWO
           
static String XML_ATT_CARD_FACE_UP
           
static String XML_ATT_CARD_INT_VALUE
           
static String XML_ATT_CARD_STRING_VALUE
           
static String XML_ATT_CARD_SUIT
           
static String XML_NAME
           
 
Fields inherited from class org.jogre.common.comm.CommTableMessage
NO_TABLE, tableNum, XML_ATT_TABLE_NUM
 
Fields inherited from class org.jogre.common.comm.CommGameMessage
status, username, usernameTo, XML_ATT_STATUS, XML_ATT_USERNAME, XML_ATT_USERNAME_TO
 
Constructor Summary
Card()
          Default constructor
Card(String card, int value, char suit)
          Constructor that takes card value.
Card(XMLElement message)
          Contructor that takes an xml message
 
Method Summary
 int compareTo(Object obj)
          Compares two Card objects based on card value.
 boolean equals(Object obj)
          Tells whether two cards are equal or not.
 XMLElement flatten()
          Flatten this object.
 String getCard()
          Getter for card string value.
 int getOrderValue()
          Get order value of card.
 char getSuit()
          Getter for the string value of the card suit.
 int getValue()
          Getter for the integer value of the card.
 boolean isFaceUp()
          Getter for if the card is face up.
 void paintComponent(Graphics g, int x, int y)
           
 void paintComponent(Graphics g, int x, int y, boolean horizontal)
           
 void setCard(String card)
          Setter for card string value.
 void setFaceUp(boolean faceUp)
          Setter for if the card is face up or down.
 void setSuit(char suit)
          Setter for the string value of the card suit.
 void setValue(int value)
          Setter for the integer value of the card.
 int spadesCompareTo(Card card)
          Compares two Card objects in the game of spades.
 String toString()
          Outputs the Card object in a string format
 
Methods inherited from class org.jogre.common.comm.CommTableMessage
flatten, getTableNum, setTableNum
 
Methods inherited from class org.jogre.common.comm.CommGameMessage
getStatus, getUsername, getUsernameTo, isUsernameSet, isUsernameToSet, setUsername, setUsernameTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CARD_PIXEL_HEIGHT

public static final int CARD_PIXEL_HEIGHT
See Also:
Constant Field Values

CARD_PIXEL_WIDTH

public static final int CARD_PIXEL_WIDTH
See Also:
Constant Field Values

CARD_SPACING

public static final int CARD_SPACING
See Also:
Constant Field Values

cardImages

public static Image cardImages

XML_NAME

public static final String XML_NAME
See Also:
Constant Field Values

XML_ATT_CARD_SUIT

public static final String XML_ATT_CARD_SUIT
See Also:
Constant Field Values

XML_ATT_CARD_STRING_VALUE

public static final String XML_ATT_CARD_STRING_VALUE
See Also:
Constant Field Values

XML_ATT_CARD_INT_VALUE

public static final String XML_ATT_CARD_INT_VALUE
See Also:
Constant Field Values

XML_ATT_CARD_FACE_UP

public static final String XML_ATT_CARD_FACE_UP
See Also:
Constant Field Values

CLUB

public static final char CLUB
See Also:
Constant Field Values

SPADE

public static final char SPADE
See Also:
Constant Field Values

DIAMOND

public static final char DIAMOND
See Also:
Constant Field Values

HEART

public static final char HEART
See Also:
Constant Field Values

TWO

public static final String TWO
See Also:
Constant Field Values

THREE

public static final String THREE
See Also:
Constant Field Values

FOUR

public static final String FOUR
See Also:
Constant Field Values

FIVE

public static final String FIVE
See Also:
Constant Field Values

SIX

public static final String SIX
See Also:
Constant Field Values

SEVEN

public static final String SEVEN
See Also:
Constant Field Values

EIGHT

public static final String EIGHT
See Also:
Constant Field Values

NINE

public static final String NINE
See Also:
Constant Field Values

TEN

public static final String TEN
See Also:
Constant Field Values

JACK

public static final String JACK
See Also:
Constant Field Values

QUEEN

public static final String QUEEN
See Also:
Constant Field Values

KING

public static final String KING
See Also:
Constant Field Values

ACE

public static final String ACE
See Also:
Constant Field Values

cardStringValues

public static final String[] cardStringValues

cardIntValues

public static final int[] cardIntValues

cardIntOrderValues

public static final int[] cardIntOrderValues
Constructor Detail

Card

public Card()
Default constructor


Card

public Card(String card,
            int value,
            char suit)
Constructor that takes card value. Card is defaulted to face down, until flipped over.

Parameters:
card - String value of card.
value - Integer value of card
suit - String value of suit of card.

Card

public Card(XMLElement message)
Contructor that takes an xml message

Parameters:
message -
Throws:
TransmissionException
Method Detail

getCard

public String getCard()
Getter for card string value.

Returns:
Returns the card string value.

setCard

public void setCard(String card)
Setter for card string value.

Parameters:
card - The card string value to set.

isFaceUp

public boolean isFaceUp()
Getter for if the card is face up.

Returns:
Returns if the card is face up.

setFaceUp

public void setFaceUp(boolean faceUp)
Setter for if the card is face up or down.

Parameters:
faceUp - Sets whether or not the card is face up or not.

getSuit

public char getSuit()
Getter for the string value of the card suit.

Returns:
Returns the suit.

setSuit

public void setSuit(char suit)
Setter for the string value of the card suit.

Parameters:
suit - The suit to set.

getValue

public int getValue()
Getter for the integer value of the card.

Returns:
Returns the value.

setValue

public void setValue(int value)
Setter for the integer value of the card.

Parameters:
value - The value to set.

getOrderValue

public int getOrderValue()
Get order value of card. This is usually used for sorting cards, especially face cards where all face card values are 10 but a king is greater than a queen. This is where order value comes in. A king will return a higher order value than a queen.

Returns:
order value of card

spadesCompareTo

public int spadesCompareTo(Card card)
Compares two Card objects in the game of spades.

Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(Object obj)
Compares two Card objects based on card value. Here, a king will be equal to a queen.

Specified by:
compareTo in interface Comparable
Parameters:
obj - The Card object to compare to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equals

public boolean equals(Object obj)
Tells whether two cards are equal or not.

See Also:
Object.equals(java.lang.Object)

toString

public String toString()
Outputs the Card object in a string format

Overrides:
toString in class CommGameMessage
See Also:
Object.toString()

flatten

public XMLElement flatten()
Flatten this object.

Specified by:
flatten in interface ITransmittable
Returns:
XML version of the state of an object which can be constructed again.
See Also:
ITransmittable.flatten()

paintComponent

public void paintComponent(Graphics g,
                           int x,
                           int y)

paintComponent

public void paintComponent(Graphics g,
                           int x,
                           int y,
                           boolean horizontal)