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


Constructor Index

 o PlayerLock()
 o PlayerLock(String)
requests a unique ID

Method Index

 o allows(Action)
This method is used when an action is being attempted.
 o consistent(Lock)
This routine is used to determine if this lock can coexist with this older lock.
 o equals(Object)
Used to compare locks
 o getID()
returns the player's ID number
 o keyWorksWith(Lock)
The user has the key to the current lock, is the lock still legal.
 o releaseAfterUsing()
Should this lock be released after it has been used only once
 o 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.

Constructors

 o 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
 o PlayerLock
 public PlayerLock()
Returns:
a player lock, one should be used for each participant in a game

Methods

 o getID
 public int getID()
returns the player's ID number

Returns:
returns the player's ID number
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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