iface
Interface Command

All Known Implementing Classes:
Alias, Drop, Examine, Help, Inventory, Kate, Look, Move, Open, Quit, Take, Talk, Use

public interface Command

Datatype that abstracts a basic game command entered at the game prompt.


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.
 java.lang.String toString()
           
 

Method Detail

exec

void exec(Player p)
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.

Parameters:
p - is the main player. The player is passed to exec because a lot of useful info, such as the current room, are attached to the Player class.

construct

void construct(java.lang.String[] params)
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.

Parameters:
Array - of arguments to construct the command. Commands can take no arguments.

toString

java.lang.String toString()
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".