Package jadex.bdi.examples.blackjack
Class CardSet
- java.lang.Object
-
- jadex.bdi.examples.blackjack.CardSet
-
public class CardSet extends java.lang.ObjectThis 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.StringACEstatic java.lang.StringCLUBstatic java.lang.StringDIAMONDstatic java.lang.StringHEARTstatic java.lang.StringJACKstatic java.lang.StringKINGstatic intNUMBER_CARDSstatic intNUMBER_PACKSstatic java.lang.StringQUEENstatic java.lang.StringSPADE
-
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 intcalculateDeckValue(Card[] cards)This method calculates the overall value of a cardSet.CarddrawCard()This method returns a randomly chosen card from the cardSet.java.lang.StringtoString()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:
toStringin classjava.lang.Object- Returns:
- A string representation of the card set.
-
-