document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  * This class is the main class of the "World of Zuul" application.
  3.  * "World of Zuul" is a very simple, text based adventure game.    
  4.  *
  5.  * This class holds information about a command that was issued by the user.
  6.  * A command currently consists of two strings: a command word and a second
  7.  * word (for example, if the command was "take map", then the two strings
  8.  * obviously are "take" and "map").
  9.  *
  10.  * The way this is used is: Commands are already checked for being valid
  11.  * command words. If the user entered an invalid command (a word that is
  12.  * not known) then the command word is <null>.
  13.  *
  14.  * If the command had only one word, then the second word is <null>.
  15.  *
  16.  * @author Naufaliando
  17.  * @version 1.0
  18.  */
  19.  
  20. class Command
  21. {
  22.     private String commandWord;
  23.     private String secondWord;
  24.  
  25.     /**
  26.      * Create a command object. First and second word must be supplied, but
  27.      * either one (or both) can be null. The command word should be null to
  28.      * indicate that this was a command that is not recognised by this game.
  29.      */
  30.     public Command(String firstWord, String secondWord)
  31.     {
  32.         commandWord = firstWord;
  33.         this.secondWord = secondWord;
  34.     }
  35.  
  36.     /**
  37.      * Return the command word (the first word) of this command.
  38.      * If the command was not understood, the result is null.
  39.      */
  40.     public String getCommandWord()
  41.     {
  42.         return commandWord;
  43.     }
  44.  
  45.     /**
  46.      * Return the second word of this command. Returns null
  47.      * if there was no second word.
  48.      */
  49.     public String getSecondWord()
  50.     {
  51.         return secondWord;
  52.     }
  53.  
  54.     /**
  55.      * Return true if this command was not understood.
  56.      */
  57.     public boolean isUnknown()
  58.     {
  59.         return (commandWord == null);
  60.     }
  61.  
  62.     /**
  63.      * Return true if the command has a second word.
  64.      */
  65.     public boolean hasSecondWord()
  66.     {
  67.         return (secondWord != null);
  68.     }
  69. }
');