de.kosi.gui.model
Class CCard

java.lang.Object
  |
  +--de.kosi.gui.model.CCard

public class CCard
extends java.lang.Object

The client-side representation of a card. Very similar to de.kosi.model.game.Card.


Field Summary
protected static CCard[] CARD
          All cards in an array.
protected  int index
          The index of this card.
 
Constructor Summary
protected CCard(int index)
          Creates a card with the given index.
 
Method Summary
static CCard getBack()
          Gets a card that shows a back side.
static CCard getCard(Card gameCard)
          Gets the card corresponding to the de.kosi.model.game.Card card.
static CCard getCard(int index)
          Gets the card with the given index.
static CCard getCard(int suit, int value)
          Gets the card with the specified suit and value.
static java.util.Vector getCards(java.util.Collection gameCards)
          Gets a Collection of CCard objects corresponding to the de.kosi.model.game.Card Collection.
 int getIndex()
          Gets the index of this card.
protected static int getIndex(Card gameCard)
          Gets the index of the given card.
protected static int getIndex(int suit, int value)
          Gets the index of a card with the given suit and value.
 int getSuit()
          Gets the suit of this card.
 int getValue()
          Gets the value of this card.
 int hashCode()
          A hash code for using this card as an hash key.
 boolean isBack()
          Tells if this card is a card back or not.
 Card toGameCard()
          Gets the de.kosi.model.game.Card instance corresponding to this card.
 java.lang.String toString()
          A string representation of this card.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected int index
The index of this card.

CARD

protected static CCard[] CARD
All cards in an array.
Constructor Detail

CCard

protected CCard(int index)
Creates a card with the given index.
Parameters:
index - the index of the new card.
Method Detail

getCard

public static CCard getCard(int index)
Gets the card with the given index.
Parameters:
index - the index of the card.
Returns:
The card with the given index.

getCard

public static CCard getCard(Card gameCard)
Gets the card corresponding to the de.kosi.model.game.Card card.
Parameters:
gameCard - the other card.
Returns:
the corresponding card.

getCard

public static CCard getCard(int suit,
                            int value)
Gets the card with the specified suit and value.
Parameters:
suit - the suit of the card.
value - the value of the card.
Returns:
the card with the specified suit and value.

getBack

public static CCard getBack()
Gets a card that shows a back side.
Returns:
the back card.

getIndex

protected static int getIndex(Card gameCard)
Gets the index of the given card.
Parameters:
gameCard - the card
Returns:
the index for that card.

getIndex

protected static int getIndex(int suit,
                              int value)
Gets the index of a card with the given suit and value.
Parameters:
suit - the suit of the card
value - the value of the card
Returns:
the index of the card

getSuit

public int getSuit()
Gets the suit of this card.
Returns:
one of the CConstants_SUIT_X constants.

getValue

public int getValue()
Gets the value of this card.
Returns:
one of the CConstants_VALUE_X constants.

getIndex

public int getIndex()
Gets the index of this card.
Returns:
the index of this card.

isBack

public boolean isBack()
Tells if this card is a card back or not.
Returns:
true if this is a card back.

toGameCard

public Card toGameCard()
Gets the de.kosi.model.game.Card instance corresponding to this card.
Returns:
Gets the de.kosi.model.game.Card instance corresponding to this card.

toString

public java.lang.String toString()
A string representation of this card.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this card.

hashCode

public int hashCode()
A hash code for using this card as an hash key.
Overrides:
hashCode in class java.lang.Object
Returns:
the index of this card.

getCards

public static java.util.Vector getCards(java.util.Collection gameCards)
Gets a Collection of CCard objects corresponding to the de.kosi.model.game.Card Collection.
Parameters:
gameCards - a collection of Card objects.
Returns:
a collection of CCard objects.