|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.kosi.model.game.Card
This class represents a card. Each card has a suit and a value. Suits can be spades, hearts, diamonds and clubs, values range from 2 over 10, jack, queen and king to ace. Since we need exactly one instance of every card this class provides an array constant CARDS of all 52 needed card instances. Constants for the suits and values are also provided.
ChangeLog:
$Log: Card.java,v $ Revision 1.2 2001/06/15 09:33:27 betacarotine Changed the Game-interface. Instead of int getLatestLeader() and List getLatestTrick() we now have Trick getLatestTrick() The internal representation and storage of the tricks is reimplemented too based on the new Trick-class. Revision 1.1.1.1 2001/04/29 18:05:18 jiriki Imported sources from zola. Revision 1.13 2001/03/30 09:33:04 wombat Removed Bug in Sorting order of card comparator. Revision 1.12 2001/03/23 10:48:52 wombat - Table now restarts game - began GuestUser implementation Revision 1.11 2001/03/21 20:14:32 login updated docs Revision 1.10 2001/03/21 19:18:16 login updated docs and removed one bug from getComparator Revision 1.9 2001/03/21 13:26:36 wombat - Removed bugs in Table - began implementation of stree client - updated documentation Revision 1.8 2001/03/21 09:14:12 login Added the method getCardComparator Revision 1.7 2001/03/18 17:32:03 wombat Changed database concept Revision 1.6 2001/03/15 19:19:48 login Worked on GameImpl to make it possible that the declarer plays the dummy's cards and prohibit that the dummy does anything. Revision 1.5 2001/02/26 15:21:37 wombat worked on GamImpl and Board Revision 1.4 2001/02/09 19:26:32 login Doc-Update Revision 1.3 2001/02/07 10:28:52 login Updated documentation!!!! Revision 1.2 2001/02/06 14:37:08 login Updated docs
Field Summary | |
static char[] |
CARD_CHARS
Char representation of the cards. |
static Card[] |
CARDS
This array constant contains one instance of every card. |
static int |
NUM_CARDS
There is for every combination of suit and value exactly one card, so it is easy to calculate the total number of cards. |
static int |
NUM_CARDS_PER_PLAYER
Number of cards each player has. |
static int |
NUM_SUITS
Number of suits. |
static int |
NUM_VALUES
Number of values. 2 over 10, jack, queen, king to ace sum up to 13 values. |
static char[] |
SUIT_CHARS
Char representation of the four suits. |
static int |
SUIT_CLUBS
This constant refers to the clubs suit. |
static int |
SUIT_DIAMONDS
This constant refers to the diamonds suit. |
static int |
SUIT_HEARTS
This constant refers to the hearts suit. |
static int |
SUIT_SPADES
This constant refers to the spades suit. |
static int |
VALUE_10
This constant refers to the 10 value. |
static int |
VALUE_2
This constant refers to the 2 value. |
static int |
VALUE_3
This constant refers to the 3 value. |
static int |
VALUE_4
This constant refers to the 4 value. |
static int |
VALUE_5
This constant refers to the 5 value. |
static int |
VALUE_6
This constant refers to the 6 value. |
static int |
VALUE_7
This constant refers to the 7 value. |
static int |
VALUE_8
This constant refers to the 8 value. |
static int |
VALUE_9
This constant refers to the 9 value. |
static int |
VALUE_ACE
This constant refers to the ace value. |
static int |
VALUE_JACK
This constant refers to the jack value. |
static int |
VALUE_KING
This constant refers to the king value. |
static int |
VALUE_QUEEN
This constant refers to the queen value. |
Constructor Summary | |
protected |
Card()
This constructor creates a card with an invalid value. |
Method Summary | |
java.lang.Object |
clone()
Returns this card instance since every card exists exactly one time. |
boolean |
equals(java.lang.Object obj)
Checks whether this card instance is equal to the given argument. |
static Card |
getCard(int card)
Returns the card stored in the CARDS array constant at the specified index. |
static Card |
getCard(int suit,
int value)
Returns the card with the specified suit and value. |
static java.util.Comparator |
getComparator(int trumpSuit,
int suitToFollow,
boolean ascending)
Returns a comparator for cards. |
int |
getSuit()
Returns the suit of this card instance. |
int |
getValue()
Returns the value of this card instance. |
int |
hashCode()
Returns the hash code of this card instance. |
java.lang.String |
toString()
Returns a String representation of this card. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final char[] SUIT_CHARS
public static final char[] CARD_CHARS
public static final int NUM_SUITS
public static final int NUM_VALUES
public static final int NUM_CARDS
public static final int NUM_CARDS_PER_PLAYER
public static final Card[] CARDS
public static final int SUIT_SPADES
public static final int SUIT_HEARTS
public static final int SUIT_DIAMONDS
public static final int SUIT_CLUBS
public static final int VALUE_ACE
public static final int VALUE_KING
public static final int VALUE_QUEEN
public static final int VALUE_JACK
public static final int VALUE_10
public static final int VALUE_9
public static final int VALUE_8
public static final int VALUE_7
public static final int VALUE_6
public static final int VALUE_5
public static final int VALUE_4
public static final int VALUE_3
public static final int VALUE_2
Constructor Detail |
protected Card()
Method Detail |
public static Card getCard(int card)
card
- The index to the desired card in the CARDS array
constant.ArrayIndexOutOfBoundsException
- If the given index was
invalid.public static Card getCard(int suit, int value)
suit
- The suit of the card to get. Must be one of the
constants SUIT_SPADES ... SUIT_CLUBS.value
- The value of the card to get. Must be one of the
constants VALUE_2 ... VALUE_ACE.java.lang.IllegalArgumentException
- If the suit or value were illegal.public int getSuit()
public int getValue()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- This argument will be compared to this card instance.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.Comparator getComparator(int trumpSuit, int suitToFollow, boolean ascending)
trumpSuit
- The suit which is trump.suitToFollow
- The suit which is to be followed; that is the
suit of the first card in a trick.ascending
- true
, if you want the cards in
ascending order, otherwise false
.java.lang.IllegalArgumentException
- If trumpSuit or suitToFollow
were no legal suits (trumpSuit may also be
SuitBid.SUIT_NO_TRUMPS).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |