All Packages Class Hierarchy This Package Previous Next Index
Class ncsa.habanero.TurnLock
java.lang.Object
|
+----ncsa.habanero.Lock
|
+----ncsa.habanero.TurnLock
- public class TurnLock
- extends Lock
TurnLock - a limitation on the types of action that can be performed
-
TurnLock()
-
-
TurnLock(int)
-
requests a turn with the participant's ID number
-
TurnLock(String)
-
requests a turn with the participant's name
-
allows(Action)
-
This method is used when an action is being attempted.
-
blocks(Action)
-
-
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 turn's ID number
-
getName()
-
returns the turn's name
-
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
TurnLock
public TurnLock(String szInitName)
- requests a turn with the participant's name
- Parameters:
- szInitName - the name or identifier of the player
- Returns:
- a lock to request a turn
TurnLock
public TurnLock(int nNewID)
- requests a turn with the participant's ID number
- Parameters:
- nNewID - the person's ID number
- Returns:
- a lock to request a turn
TurnLock
public TurnLock()
- Returns:
- a player lock, one should be used for each participant in a game
getID
public int getID()
- returns the turn's ID number
- Returns:
- returns the turn's ID number
getName
public String getName()
- returns the turn's name
- Returns:
- returns the turn's ID name
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 true, since this allows any action in turn
- Overrides:
- allows in class Lock
blocks
public boolean blocks(Action act)
- Parameters:
- act - the action that is being attempted without a lock
- Returns:
- returns true if the action is not allowed by the lock,
we'll be nice and not allow actions while someone is
taking their turn
- Overrides:
- blocks 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 no other turn locks exist
- 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:
- always returns true, since if you have the key,
this lock doesn't interfere
- Overrides:
- keyWorksWith in class Lock
releaseAfterUsing
public boolean releaseAfterUsing()
- Should this lock be released after it has been used only once
- Returns:
- this lock is used to take a turn, only one turn
- 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