dd.sim
Class Player

java.lang.Object
  extended bydd.sim.SimObject
      extended bydd.sim.Player
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Player
extends SimObject
implements java.lang.Comparable

A simple class template. The idea is that you can copy this file and modify stuff where necessary. It provides examples of javadoc comments and basic formatting conventions. Hopefully this is useful for cutting and pasting.

If you want to start a new paragraph in Javadoc, you need a blank line and paragraph tags, as shown here. Note the closing tag for a paragraph is optional.

Author:
Eric Scharff
See Also:
Serialized Form

Field Summary
 
Fields inherited from class dd.sim.SimObject
attributes
 
Constructor Summary
Player()
          The null constructor creates the "nobody" player and should never be called directly.
Player(int turnNumber, java.lang.String name)
          Creates a new player object.
 
Method Summary
 int compareTo(java.lang.Object o)
           
 void disconnected()
           
 boolean equals(java.lang.Object other)
           
 int getFavors()
           
 int getFavorsPerTurn()
           
 java.lang.String getName()
           
 java.lang.String getPlayerID()
           
 java.lang.String getRole()
           
 int getTurnNumber()
           
 int getVotes()
           
 boolean isConnected()
           
static void main(java.lang.String[] args)
           
static Player nobody()
          Returns the "nobody" player.
 void reset()
           
 void setConnected(boolean connected)
           
 void setName(java.lang.String name)
           
 void setRole(java.lang.String role)
           
 void setVotes(int votes)
           
 void spendVotes(int votes)
          spendVotes decrements votes first, and when there are no votes left, spends favors to get extra votes on a one-for-one basis.
 
Methods inherited from class dd.sim.SimObject
addPropertyChangeListener, addPropertyChangeListener, debug, duplicate, error, fatal, filter, filter, firePropertyChange, getAttribute, getAttribute, getAttributes, getGlobalAttribute, getObjectAttribute, getObjectAttribute, incrementAttribute, incrementAttribute, isSet, log, out, readFromXML, readFromXML, removeAttribute, removePropertyChangeListener, setAttribute, setAttribute, setAttribute, setAttributes, setGlobalAttribute, warning, writeText, writeXML, writeXML
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Player

public Player()
The null constructor creates the "nobody" player and should never be called directly. However, it needs to remain public for XML serialization.


Player

public Player(int turnNumber,
              java.lang.String name)
Creates a new player object. A Player's name field can be changed, but no method is provided for altering the turnNumber attribute because it is what identifies the Player uniquely. The constructor calls reset() to set votes and favors.

Method Detail

nobody

public static Player nobody()
Returns the "nobody" player. Sometimes something is not owned by anyone, which is different than having a NULL value. The nobody player is used in these comparisons.

Returns:
a player object that represents no player

isConnected

public boolean isConnected()

disconnected

public void disconnected()

setConnected

public void setConnected(boolean connected)

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getRole

public java.lang.String getRole()

setRole

public void setRole(java.lang.String role)

getPlayerID

public java.lang.String getPlayerID()

getTurnNumber

public int getTurnNumber()

getFavorsPerTurn

public int getFavorsPerTurn()

reset

public void reset()

setVotes

public void setVotes(int votes)

getVotes

public int getVotes()

getFavors

public int getFavors()

spendVotes

public void spendVotes(int votes)
spendVotes decrements votes first, and when there are no votes left, spends favors to get extra votes on a one-for-one basis. The "votes" argument should be positive, and should not be more than favorPerTurn+1, but neither case is checked for.


equals

public boolean equals(java.lang.Object other)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

main

public static void main(java.lang.String[] args)