trizehn

Command

Nov 18th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. /**
  2.  * Write a description of class Command here.
  3.  *
  4.  * @author Daffa Tristan Firdaus
  5.  * @version 18 November 2020
  6.  */
  7.  
  8. public class Command
  9. {
  10.     private String commandWord;
  11.     private String secondWord;
  12.  
  13.  
  14.     public Command(String firstWord, String secondWord)
  15.     {
  16.         commandWord = firstWord;
  17.         this.secondWord = secondWord;
  18.     }
  19.  
  20.     /**
  21.      * Return the command word (the first word) of this command. If the
  22.      * command was not understood, the result is null.
  23.      * @return String commandWord
  24.      */
  25.     public String getCommandWord()
  26.     {
  27.         return commandWord;
  28.     }
  29.  
  30.     /**
  31.      * Return the second word of this command. Returns null if there was no
  32.      * second word.
  33.      * @return String secondWord
  34.      */
  35.     public String getSecondWord()
  36.     {
  37.         return secondWord;
  38.     }
  39.  
  40.     /**
  41.      * Return true if this command was not understood.
  42.      * @return bool
  43.      */
  44.     public boolean isUnknown()
  45.     {
  46.         return (commandWord == null);
  47.     }
  48.  
  49.     /**
  50.      * Return true if the command has a second word.
  51.      * @return bool
  52.      */
  53.     public boolean hasSecondWord()
  54.     {
  55.         return (secondWord != null);
  56.     }
  57. }
Add Comment
Please, Sign In to add comment