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 Rizqi Rifaldi
  17.  * @version 0.1
  18.  */
  19.  
  20. class Command{
  21.     private String commandWord;
  22.     private String secondWord;
  23.  
  24.     /**
  25.      * Create a command object. First and second word must be supplied, but
  26.      * either one (or both) can be null. The command word should be null to
  27.      * indicate that this was a command that is not recognised by this game.
  28.      */
  29.     public Command(String firstWord, String secondWord){
  30.         commandWord = firstWord;
  31.         this.secondWord = secondWord;
  32.     }
  33.  
  34.     /**
  35.      * Return the command word (the first word) of this command.
  36.      * If the command was not understood, the result is null.
  37.      */
  38.     public String getCommandWord(){
  39.         return commandWord;
  40.     }
  41.  
  42.     /**
  43.      * Return the second word of this command. Returns null
  44.      * if there was no second word.
  45.      */
  46.     public String getSecondWord(){
  47.         return secondWord;
  48.     }
  49.  
  50.     /**
  51.      * Return true if this command was not understood.
  52.      */
  53.     public boolean isUnknown(){
  54.         return (commandWord == null);
  55.     }
  56.  
  57.     /**
  58.      * Return true if the command has a second word.
  59.      */
  60.     public boolean hasSecondWord(){
  61.         return (secondWord != null);
  62.     }
  63. }
');