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


Constructor Index

 o TurnLock()
 o TurnLock(int)
requests a turn with the participant's ID number
 o TurnLock(String)
requests a turn with the participant's name

Method Index

 o allows(Action)
This method is used when an action is being attempted.
 o blocks(Action)
 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 turn's ID number
 o getName()
returns the turn's name
 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

Constructors

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

Methods

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

Returns:
returns the turn's ID number
 o getName
 public String getName()
returns the turn's name

Returns:
returns the turn's ID name
 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 true, since this allows any action in turn
Overrides:
allows in class Lock
 o 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
 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 no other turn locks exist
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:
always returns true, since if you have the key, this lock doesn't interfere
Overrides:
keyWorksWith in class Lock
 o 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
 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