Class ItemCommand
Object
ItemCommand
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreturns the regular expression the command structure must follow.protected static String[]
parseCommand
(String aCommand) split up the command into different words.protected static String[]
parseCommand
(String aCommand, int limit) split up the command into different words.abstract DisplayInterface
Runs the command.
-
Constructor Details
-
ItemCommand
Constructor.- Parameters:
aRegExpr
- a regular expression to which the command should follow. For example "give [A..Za..z]*1-4 to [A..Za..z]*". %me is a parameter that can be used when the name of the character playing is requested.
-
-
Method Details
-
getRegExpr
Description copied from interface:Command
returns the regular expression the command structure must follow.- Specified by:
getRegExpr
in interfaceCommand
- Returns:
- String containing the regular expression.
- See Also:
-
run
Description copied from interface:Command
Runs the command. The usual sequence of events is:- parsing the command string
- retrieving the appropriate information items/rooms/characters/etc)
- doing the action
- composing a return message for the user.
-
parseCommand
-
parseCommand
split up the command into different words. For example: parseCommand("bow to Marvin evilly", 4) returns array ["bow","to","Marvin", "evilly"] parseCommand("say to Marvin Greetings this morning.", 4) returns array ["say","to","Marvin", "Greetings this morning."]- Parameters:
aCommand
- String containing the commandlimit
- the result threshold, example 3 means the array holds three, the first two words and the rest in the third array element.- Returns:
- String array where each String contains a word from the command.
- See Also:
-