|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--de.uni_paderborn.robots.robotArenaInterface.ItemData
|
+--de.uni_paderborn.robots.robotArenaInterface.CardData
This class represents the cards of a common poker game.
In a poker game a card has a color and a value.
Colors: DIAMOND, HEART, SPADE, CLUB
Values: TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, LADY, KING, ACE
Poker has 10 card combinations. If the card combinations of two hands differ then the hand with the higher card combination has the higher score.
Card combinations in ascending order from lowest to highest :
NOTHING
ONE_PAIR
TWO_PAIRS
THREE_OF_A_KIND
STRAIGHT
FLUSH
FULL_HOUSE
FOUR_OF_A_KIND
STRAIGHT_FLUSH
ROYAL_FLUSHCardConstants.
Implement the interface in your class to use these values.
The static method getHandValue(CardData[])
can be used to calculate a poker score.
PutAction,
ExchangeAction,
RobotData| Field Summary | |
private static byte |
CARD_BASE
base used to calculate the score |
private byte |
color
color of card |
private static boolean |
DEBUG
constant controlling DEBUG output |
private byte |
value
value of the card |
| Fields inherited from interface de.uni_paderborn.robots.robotArenaInterface.CardConstants |
ACE, CLUB, DIAMOND, EIGHT, FIVE, FLUSH, FOUR, FOUR_OF_A_KIND, FULL_HOUSE, HEART, JACK, KING, LADY, NINE, NOTHING, ONE_PAIR, ROYAL_FLUSH, SEVEN, SIX, SPADE, STRAIGHT, STRAIGHT_FLUSH, TEN, THREE, THREE_OF_A_KIND, TWO, TWO_PAIRS |
| Constructor Summary | |
CardData(byte color,
byte value)
Constructs a new CardData object with specified value and color. |
|
| Method Summary | |
static CardData[] |
cardSort(CardData[] cards)
Constructs a sorted and cloned array of CardData objects.
|
java.lang.Object |
clone()
Constructs an exact copy of this CardData object. |
int |
compareTo(java.lang.Object o)
Compares two CardData objects.
|
private static byte |
getCardScore(CardData card)
Calculates the score of a reference to CardData. |
byte |
getColor()
Returns the color of this card. |
static int |
getHandValue(CardData[] hand)
Calculates a score which is based on poker rules. |
byte |
getValue()
Returns the value of this card. |
static java.lang.String |
stringTypeOfScore(int score)
Converts a score value into a typeOfScore which is converted into a readable String. |
java.lang.String |
toString()
Returns the string representation of this CardData object. |
static int |
typeOfScore(int score)
Calculate the type of the score. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static final byte CARD_BASE
private static final boolean DEBUG
private byte value
private byte color
| Constructor Detail |
public CardData(byte color,
byte value)
throws java.lang.IllegalArgumentException
color - color of the new card ( HEART, DIAMOND, SPADE or CLUB )value - value of the new card ( TWO, ..., TEN, JACK, LADY, KING, ACE )java.lang.IllegalArgumentException - If color or value are out of bounds.CardConstants| Method Detail |
public byte getColor()
CardConstantspublic byte getValue()
CardConstantsprivate static byte getCardScore(CardData card)
card is null then 0 is returned.
Else the value of the CardData object minus one is returned.card - CardData reference to be checked.0..ACE-1getHandValue(de.uni_paderborn.robots.robotArenaInterface.CardData[]),
CardConstantspublic int compareTo(java.lang.Object o)
CardData objects.
a.compareTo(b) is
| negative | for a < b |
| 0 | for a == b |
| positive | for a > b |
CardDatais ordered by Value and then by Color.
compareTo in interface java.lang.ComparableCardData is less than, equal to, or greater than the specified object.Comparablepublic java.lang.Object clone()
CardData object.clone in class java.lang.ObjectCardData object.Cloneablepublic static CardData[] cardSort(CardData[] cards)
CardData objects.
CardData objects.
compareTo(Object) is used to sort the cards in ascending order.cards - Must not be null. The first 5, different CardData objects in the array are sorted and returned.null references. If no cards are found null is returned.compareTo(java.lang.Object)public static int getHandValue(CardData[] hand)
CardConstants,
cardSort(de.uni_paderborn.robots.robotArenaInterface.CardData[])public static int typeOfScore(int score)
CardConstantspublic static java.lang.String stringTypeOfScore(int score)
typeOfScore(int) is called to determine the type of the score.public java.lang.String toString()
CardData object.toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||