Class Command
java.lang.Object
Command
public class Command
- extends Object
This class is part of the "World of Zuul" application.
"World of Zuul" is a very simple, text based adventure game.
This class holds information about a command that was issued by the user.
A command currently consists of two parts: a CommandWord and a string
(for example, if the command was "take map", then the two parts
are TAKE and "map").
The way this is used is: Commands are already checked for being valid
command words. If the user entered an invalid command (a word that is not
known) then the CommandWord is UNKNOWN.
If the command had only one word, then the second word is .
- Version:
- 2006.03.30
- Author:
- Michael Kolling and David J. Barnes
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Command
public Command(CommandWord commandWord,
String secondWord)
- Create a command object. First and second words must be supplied, but
the second may be null.
- Parameters:
commandWord
- The CommandWord. UNKNOWN if the command word
was not recognised.secondWord
- The second word of the command. May be null.
getCommandWord
public CommandWord getCommandWord()
- Return the command word (the first word) of this command.
- Returns:
- The command word.
getSecondWord
public String getSecondWord()
- Returns:
- The second word of this command. Returns null if there was no
second word.
hasSecondWord
public boolean hasSecondWord()
- Returns:
- true if the command has a second word.
isUnknown
public boolean isUnknown()
- Returns:
- true if this command was not understood.