Class Command
- java.lang.Object
-
- Command
-
class Command extends java.lang.Object
This class is the main class 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 strings: a command word and a second word (for example, if the command was "take map", then the two strings obviously 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 command word is. If the command had only one word, then the second word is . - Version:
- 1.0 (February 2002)
- Author:
- Michael Kolling and David J. Barnes
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcommandWordprivate java.lang.StringsecondWord
-
Constructor Summary
Constructors Constructor Description Command(java.lang.String firstWord, java.lang.String secondWord)Create a command object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetCommandWord()Return the command word (the first word) of this command.java.lang.StringgetSecondWord()Return the second word of this command.booleanhasSecondWord()Return true if the command has a second word.booleanisUnknown()Return true if this command was not understood.
-
-
-
Field Detail
-
commandWord
private java.lang.String commandWord
-
secondWord
private java.lang.String secondWord
-
-
Constructor Detail
-
Command
public Command(java.lang.String firstWord, java.lang.String secondWord)
Create a command object. First and second word must be supplied, but either one (or both) can be null. The command word should be null to indicate that this was a command that is not recognised by this game.
-
-
Method Detail
-
getCommandWord
public java.lang.String getCommandWord()
Return the command word (the first word) of this command. If the command was not understood, the result is null.
-
getSecondWord
public java.lang.String getSecondWord()
Return the second word of this command. Returns null if there was no second word.
-
isUnknown
public boolean isUnknown()
Return true if this command was not understood.
-
hasSecondWord
public boolean hasSecondWord()
Return true if the command has a second word.
-
-