Class Player

  • Direct Known Subclasses:
    Dealer

    public class Player
    extends java.lang.Object
    Representation of a player.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int account
      The player's account.
      protected IComponentIdentifier aid
      The player's agent id.
      protected int bet
      The player's current bet.
      protected java.util.List cards
      The cards held by the player.
      protected java.awt.Color color
      The player's color.
      protected java.lang.Integer colorvalue
      Hack, necessary because in Java Color is not a bean.
      protected boolean drawcard
      The player's decision if to draw another card.
      protected int games
      The game counter (incremented when a game is started).
      protected java.lang.String name
      The player's name.
      protected SimplePropertyChangeSupport pcs
      The helper object for bean events.
      protected java.lang.String state
      The player state.
      static java.lang.String STATE_FINISHED
      State of a player when all cards are drawn.
      static java.lang.String STATE_GAME_STARTED
      State of a player at game start.
      static java.lang.String STATE_IDLE
      State of a player that is not involved in a game.
      static java.lang.String STATE_PLAYING
      State of a player, after bet is made.
      static java.lang.String STATE_UNREGISTERED
      State of a player that is not involved in a game.
      protected IStrategy strategy
      The player's strategy.
      protected java.lang.String strategyname
      The strategyname.
    • Constructor Summary

      Constructors 
      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.
    • Field Detail

      • STATE_UNREGISTERED

        public static final java.lang.String STATE_UNREGISTERED
        State of a player that is not involved in a game.
        See Also:
        Constant Field Values
      • STATE_IDLE

        public 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_STARTED

        public static final java.lang.String STATE_GAME_STARTED
        State of a player at game start.
        See Also:
        Constant Field Values
      • STATE_PLAYING

        public static final java.lang.String STATE_PLAYING
        State of a player, after bet is made.
        See Also:
        Constant Field Values
      • STATE_FINISHED

        public static final java.lang.String STATE_FINISHED
        State of a player when all cards are drawn.
        See Also:
        Constant Field Values
      • name

        protected java.lang.String name
        The player's name.
      • account

        protected int account
        The player's account.
      • color

        protected java.awt.Color color
        The player's color.
      • colorvalue

        protected java.lang.Integer colorvalue
        Hack, necessary because in Java Color is not a bean.
      • strategyname

        protected java.lang.String strategyname
        The strategyname.
      • strategy

        protected IStrategy strategy
        The player's strategy.
      • state

        protected java.lang.String state
        The player state.
      • bet

        protected int bet
        The player's current bet.
      • drawcard

        protected boolean drawcard
        The player's decision if to draw another card.
      • cards

        protected java.util.List cards
        The cards held by the player.
      • games

        protected int games
        The game counter (incremented when a game is started).
    • Constructor Detail

      • Player

        public Player()
        Empty bean constructor.
      • Player

        public Player​(java.lang.String name,
                      int account,
                      java.awt.Color color,
                      java.lang.String strategyname)
        Create a new Player.
      • Player

        public Player​(IComponentIdentifier aid,
                      java.lang.String name,
                      int account,
                      java.awt.Color color,
                      java.lang.String strategyname)
        Create a new Player.
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name of the player.
      • setName

        public void setName​(java.lang.String name)
        Set the name of the player.
      • getAccount

        public int getAccount()
        Get the account of the player.
      • setAccount

        public void setAccount​(int account)
        Set the account of the player.
      • getColor

        public java.awt.Color getColor()
        Get the color of the player.
      • getColorValue

        public int getColorValue()
        Get the color value.
        Returns:
        The color value.
      • setColorValue

        public void setColorValue​(int colorvalue)
        Set the color value.
        Parameters:
        colorvalue - The color value.
      • getStrategy

        public IStrategy getStrategy()
        Get the strategy of the player.
      • getStrategyName

        public java.lang.String getStrategyName()
        Get the strategy name.
        Returns:
        The strategy name.
      • setStrategyName

        public void setStrategyName​(java.lang.String strategyname)
        Set the strategy name.
        Parameters:
        strategyname - The strategy name.
      • addCard

        public void addCard​(Card card)
        Add a card.
      • getCards

        public Card[] getCards()
        Get the cards held by the player.
      • setCards

        public void setCards​(Card[] cards)
        Get the cards held by the player.
      • getCard

        public Card getCard​(int idx)
        Get a card.
      • setCard

        public void setCard​(int idx,
                            Card card)
        Get a card.
      • getCardCnt

        public int getCardCnt()
        Get the number of cards.
      • getState

        public java.lang.String getState()
        Get the state.
      • setState

        public void setState​(java.lang.String state)
        Set the state.
      • getBet

        public int getBet()
        Get the bet.
      • setBet

        public void setBet​(int bet)
        Set the bet.
      • makeBet

        public void makeBet​(int bet)
        Make a bet.
      • getGameCount

        public int getGameCount()
        Get the game counter.
      • getMoneyWon

        public int getMoneyWon​(Card[] dealercards)
        Get the money won in the current game.
      • equals

        public boolean equals​(java.lang.Object o)
        Test if this player equals another object.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Get the hash code of this player.
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • addPropertyChangeListener

        public 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.
      • removePropertyChangeListener

        public 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.