|
|||||||||
| 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| 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.
|
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 |
|
| 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 )color or value are out of bounds.CardConstants| Method Detail |
public 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 java.lang.Object clone()
CardData object.CardData object.Cloneablepublic 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.
CardData is less than, equal to, or greater than the specified object.Comparablepublic byte getColor()
CardConstantspublic static int getHandValue(CardData[] hand)
CardConstants,
cardSort(de.uni_paderborn.robots.robotArenaInterface.CardData[])public byte getValue()
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.public static int typeOfScore(int score)
CardConstants
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||