Package jadex.bdi.examples.blackjack
Class CardSet
- java.lang.Object
-
- jadex.bdi.examples.blackjack.CardSet
-
public class CardSet extends java.lang.Object
This class represents a whole blackjack-cardSet. Blackjack-cardSets are usually composed of 6 'normal' cardSets, each containing 52 cards.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACE
static java.lang.String
CLUB
static java.lang.String
DIAMOND
static java.lang.String
HEART
static java.lang.String
JACK
static java.lang.String
KING
static int
NUMBER_CARDS
static int
NUMBER_PACKS
static java.lang.String
QUEEN
static java.lang.String
SPADE
-
Constructor Summary
Constructors Constructor Description CardSet()
Cards have to be encoded as Strings, cause they are being sent as a message's content and only Strings are allowed as the content-objects of ACLMessages (exceptions are Predicates and Actions, but these are ontology-specific objects)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
calculateDeckValue(Card[] cards)
This method calculates the overall value of a cardSet.Card
drawCard()
This method returns a randomly chosen card from the cardSet.java.lang.String
toString()
Create a string representation of the card set.
-
-
-
Field Detail
-
NUMBER_PACKS
public static final int NUMBER_PACKS
- See Also:
- Constant Field Values
-
NUMBER_CARDS
public static final int NUMBER_CARDS
- See Also:
- Constant Field Values
-
JACK
public static final java.lang.String JACK
- See Also:
- Constant Field Values
-
QUEEN
public static final java.lang.String QUEEN
- See Also:
- Constant Field Values
-
KING
public static final java.lang.String KING
- See Also:
- Constant Field Values
-
ACE
public static final java.lang.String ACE
- See Also:
- Constant Field Values
-
DIAMOND
public static final java.lang.String DIAMOND
- See Also:
- Constant Field Values
-
HEART
public static final java.lang.String HEART
- See Also:
- Constant Field Values
-
SPADE
public static final java.lang.String SPADE
- See Also:
- Constant Field Values
-
CLUB
public static final java.lang.String CLUB
- See Also:
- Constant Field Values
-
-
Method Detail
-
drawCard
public Card drawCard()
This method returns a randomly chosen card from the cardSet.- Returns:
- randomly chosen card, encoded as a String-object.
-
calculateDeckValue
public static int calculateDeckValue(Card[] cards)
This method calculates the overall value of a cardSet. The only thing to be mentioned is, that aces may count as 1 or 11, and that there is no way to influence this. Aces count 11 as long as the overAll deckValue is beneath 21. Only in case the overAll value lies above 21 and there are aces present, one (or more) aces count as a 1.
-
toString
public java.lang.String toString()
Create a string representation of the card set.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the card set.
-
-