cmd
Class Drop
java.lang.Object
cmd.Drop
- All Implemented Interfaces:
- Command
public class Drop
- extends java.lang.Object
- implements Command
Drop
When executed by a player, the drop command takes the item to be dropped
from the player's inventory (unless it's not present) and places it in the
current room's list of items.
Constructor Summary |
Drop()
|
Method Summary |
void |
construct(java.lang.String[] params)
construct is called when the Command is created. |
void |
exec(Player p)
exec is the main method of the command. |
void |
setName(java.lang.String itemToDrop)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Drop
public Drop()
exec
public void exec(Player p)
- Description copied from interface:
Command
- exec is the main method of the command. exec is called by
executeCommand in the core.Game class. Everything that should happen
when you execute the command, besides the initialisation of what
the command should execute on, should happen in this method.
- Specified by:
exec
in interface Command
- Parameters:
p
- the player executing the Drop command.
construct
public void construct(java.lang.String[] params)
- Description copied from interface:
Command
- construct is called when the Command is created. construct
should parse the params array, and get relevant information
from it. For example, if the command was "move e", the params
array would contain "e", so the construct command should set
an instance variable dir that has "e" as its value. Then,
when exec is called, it can use this information.
- Specified by:
construct
in interface Command
- Parameters:
params[]
- the parameters taken for the drop command.
setName
public void setName(java.lang.String itemToDrop)
- Parameters:
itemToDrop
- the item to be dropped
toString
public java.lang.String toString()
- Specified by:
toString
in interface Command
- Overrides:
toString
in class java.lang.Object
- Returns:
- The description of the command created for the Help
command to print when the player types "help your_cmd_name".