All Packages Class Hierarchy This Package Previous Next Index
Class ncsa.habanero.PlayerLock
java.lang.Object
|
+----ncsa.habanero.Lock
|
+----ncsa.habanero.PlayerLock
- public class PlayerLock
- extends Lock
PlayerLock - a limitation on the types of action that can be performed
-
PlayerLock()
-
-
PlayerLock(String)
-
requests a unique ID
-
allows(Action)
-
This method is used when an action is being attempted.
-
consistent(Lock)
-
This routine is used to determine if this lock can coexist with this
older lock.
-
equals(Object)
-
Used to compare locks
-
getID()
-
returns the player's ID number
-
keyWorksWith(Lock)
-
The user has the key to the current lock, is the lock still legal.
-
releaseAfterUsing()
-
Should this lock be released after it has been used only once
-
setID(int)
-
This method is used by the arbitrator to set the ID, or by the player if
they would like to request a specific number.
PlayerLock
public PlayerLock(String szInitName)
- requests a unique ID
- Parameters:
- szInitName - the name or identifier of the player
- Returns:
- a player lock, one should be used for each participant in a game
PlayerLock
public PlayerLock()
- Returns:
- a player lock, one should be used for each participant in a game
getID
public int getID()
- returns the player's ID number
- Returns:
- returns the player's ID number
setID
public void setID(int nNewID)
- This method is used by the arbitrator to set the ID, or by the player if
they would like to request a specific number. This method should only be
called by the arbitrator, if you are using a TurnTakerArbitrator.
- Parameters:
- nNewID - the new ID for this player
- Returns:
- updates the ID in the PlayerLock
allows
public boolean allows(Action act)
- This method is used when an action is being attempted. It
checks to see if the action is allowed.
- Parameters:
- act - the action that is being attempted
- Returns:
- always returns false since a player lock just identifies a person
- Overrides:
- allows in class Lock
consistent
public boolean consistent(Lock lkdRequest)
- This routine is used to determine if this lock can coexist with this
older lock.
- Parameters:
- lkdRequest - the other lock that is attempted
- Returns:
- true if someone else is asking for the same name or the same ID
- Overrides:
- consistent in class Lock
keyWorksWith
public boolean keyWorksWith(Lock ldRequest)
- The user has the key to the current lock, is the lock still legal.
- Parameters:
- ldRequest - the request that the user is making
- Returns:
- makes sure the turn and the player match
- Overrides:
- keyWorksWith in class Lock
releaseAfterUsing
public boolean releaseAfterUsing()
- Should this lock be released after it has been used only once
- Returns:
- once a player gets one of these, they have it as long as they want
- Overrides:
- releaseAfterUsing in class Lock
equals
public boolean equals(Object another)
- Used to compare locks
- Parameters:
- another - the other lock
- Returns:
- true if they have the same ID, or if one is missing an ID, then
the same name
- Overrides:
- equals in class Lock
All Packages Class Hierarchy This Package Previous Next Index