Package jadex.bdi.examples.blackjack
Class Player
- java.lang.Object
- 
- jadex.bdi.examples.blackjack.Player
 
- 
- Direct Known Subclasses:
- Dealer
 
 public class Player extends java.lang.ObjectRepresentation of a player.
- 
- 
Field SummaryFields Modifier and Type Field Description protected intaccountThe player's account.protected IComponentIdentifieraidThe player's agent id.protected intbetThe player's current bet.protected java.util.ListcardsThe cards held by the player.protected java.awt.ColorcolorThe player's color.protected java.lang.IntegercolorvalueHack, necessary because in Java Color is not a bean.protected booleandrawcardThe player's decision if to draw another card.protected intgamesThe game counter (incremented when a game is started).protected java.lang.StringnameThe player's name.protected SimplePropertyChangeSupportpcsThe helper object for bean events.protected java.lang.StringstateThe player state.static java.lang.StringSTATE_FINISHEDState of a player when all cards are drawn.static java.lang.StringSTATE_GAME_STARTEDState of a player at game start.static java.lang.StringSTATE_IDLEState of a player that is not involved in a game.static java.lang.StringSTATE_PLAYINGState of a player, after bet is made.static java.lang.StringSTATE_UNREGISTEREDState of a player that is not involved in a game.protected IStrategystrategyThe player's strategy.protected java.lang.StringstrategynameThe strategyname.
 - 
Constructor SummaryConstructors Constructor Description Player()Empty bean constructor.Player(IComponentIdentifier aid, java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)Create a new Player.Player(java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)Create a new Player.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCard(Card card)Add a card.voidaddPropertyChangeListener(PropertyChangeListener listener)Add a PropertyChangeListener to the listener list.booleanequals(java.lang.Object o)Test if this player equals another object.intgetAccount()Get the account of the player.IComponentIdentifiergetAgentID()Get the aid of the player.intgetBet()Get the bet.CardgetCard(int idx)Get a card.intgetCardCnt()Get the number of cards.Card[]getCards()Get the cards held by the player.java.awt.ColorgetColor()Get the color of the player.intgetColorValue()Get the color value.intgetGameCount()Get the game counter.intgetMoneyWon(Card[] dealercards)Get the money won in the current game.java.lang.StringgetName()Get the name of the player.java.lang.StringgetState()Get the state.IStrategygetStrategy()Get the strategy of the player.java.lang.StringgetStrategyName()Get the strategy name.inthashCode()Get the hash code of this player.voidmakeBet(int bet)Make a bet.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a PropertyChangeListener from the listener list.voidsetAccount(int account)Set the account of the player.voidsetAgentID(IComponentIdentifier aid)Set the aid of the player.voidsetBet(int bet)Set the bet.voidsetCard(int idx, Card card)Get a card.voidsetCards(Card[] cards)Get the cards held by the player.voidsetColorValue(int colorvalue)Set the color value.voidsetName(java.lang.String name)Set the name of the player.voidsetState(java.lang.String state)Set the state.voidsetStrategyName(java.lang.String strategyname)Set the strategy name.java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
STATE_UNREGISTEREDpublic static final java.lang.String STATE_UNREGISTERED State of a player that is not involved in a game.- See Also:
- Constant Field Values
 
 - 
STATE_IDLEpublic static final java.lang.String STATE_IDLE State of a player that is not involved in a game.- See Also:
- Constant Field Values
 
 - 
STATE_GAME_STARTEDpublic static final java.lang.String STATE_GAME_STARTED State of a player at game start.- See Also:
- Constant Field Values
 
 - 
STATE_PLAYINGpublic static final java.lang.String STATE_PLAYING State of a player, after bet is made.- See Also:
- Constant Field Values
 
 - 
STATE_FINISHEDpublic static final java.lang.String STATE_FINISHED State of a player when all cards are drawn.- See Also:
- Constant Field Values
 
 - 
nameprotected java.lang.String name The player's name.
 - 
accountprotected int account The player's account.
 - 
colorprotected java.awt.Color color The player's color.
 - 
colorvalueprotected java.lang.Integer colorvalue Hack, necessary because in Java Color is not a bean.
 - 
strategynameprotected java.lang.String strategyname The strategyname.
 - 
strategyprotected IStrategy strategy The player's strategy.
 - 
aidprotected IComponentIdentifier aid The player's agent id.
 - 
stateprotected java.lang.String state The player state.
 - 
betprotected int bet The player's current bet.
 - 
drawcardprotected boolean drawcard The player's decision if to draw another card.
 - 
cardsprotected java.util.List cards The cards held by the player.
 - 
gamesprotected int games The game counter (incremented when a game is started).
 - 
pcsprotected SimplePropertyChangeSupport pcs The helper object for bean events.
 
- 
 - 
Constructor Detail- 
Playerpublic Player() Empty bean constructor.
 - 
Playerpublic Player(java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname)Create a new Player.
 - 
Playerpublic Player(IComponentIdentifier aid, java.lang.String name, int account, java.awt.Color color, java.lang.String strategyname) Create a new Player.
 
- 
 - 
Method Detail- 
getNamepublic java.lang.String getName() Get the name of the player.
 - 
setNamepublic void setName(java.lang.String name) Set the name of the player.
 - 
getAccountpublic int getAccount() Get the account of the player.
 - 
setAccountpublic void setAccount(int account) Set the account of the player.
 - 
getColorpublic java.awt.Color getColor() Get the color of the player.
 - 
getColorValuepublic int getColorValue() Get the color value.- Returns:
- The color value.
 
 - 
setColorValuepublic void setColorValue(int colorvalue) Set the color value.- Parameters:
- colorvalue- The color value.
 
 - 
getStrategypublic IStrategy getStrategy() Get the strategy of the player.
 - 
getStrategyNamepublic java.lang.String getStrategyName() Get the strategy name.- Returns:
- The strategy name.
 
 - 
setStrategyNamepublic void setStrategyName(java.lang.String strategyname) Set the strategy name.- Parameters:
- strategyname- The strategy name.
 
 - 
getAgentIDpublic IComponentIdentifier getAgentID() Get the aid of the player.
 - 
setAgentIDpublic void setAgentID(IComponentIdentifier aid) Set the aid of the player.
 - 
addCardpublic void addCard(Card card) Add a card.
 - 
getCardspublic Card[] getCards() Get the cards held by the player.
 - 
setCardspublic void setCards(Card[] cards) Get the cards held by the player.
 - 
getCardpublic Card getCard(int idx) Get a card.
 - 
setCardpublic void setCard(int idx, Card card)Get a card.
 - 
getCardCntpublic int getCardCnt() Get the number of cards.
 - 
getStatepublic java.lang.String getState() Get the state.
 - 
setStatepublic void setState(java.lang.String state) Set the state.
 - 
getBetpublic int getBet() Get the bet.
 - 
setBetpublic void setBet(int bet) Set the bet.
 - 
makeBetpublic void makeBet(int bet) Make a bet.
 - 
getGameCountpublic int getGameCount() Get the game counter.
 - 
getMoneyWonpublic int getMoneyWon(Card[] dealercards) Get the money won in the current game.
 - 
equalspublic boolean equals(java.lang.Object o) Test if this player equals another object.- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() Get the hash code of this player.- Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
addPropertyChangeListenerpublic void addPropertyChangeListener(PropertyChangeListener listener) Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Parameters:
- listener- The PropertyChangeListener to be added.
 
 - 
removePropertyChangeListenerpublic void removePropertyChangeListener(PropertyChangeListener listener) Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Parameters:
- listener- The PropertyChangeListener to be removed.
 
 
- 
 
-