Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Class ini menyimpan informasi tentang command yang dikeluarkan oleh pengguna.
- * A command dari dua string: kata command dan kata kedua
- * (contoh, jika command adalah "take map", maka dua string itu
- * adalah "take" dan "map").
- *
- * Cara penggunaannya adalah: Commands udah diperiksa untuk menjadi
- * kata command yang valid. Jika pengguna memasukkan command yang tidak valid
- * (kata yang tidak dikenal) maka kata command word adalah <null>.
- *
- * Jika command hanya punya satu kata, maka kata keduanya <null>.
- *
- * @author M. Rayhan Raffi P.
- * @version 16-11-2020
- */
- public class Command
- {
- private String commandWord;
- private String secondWord;
- /**
- * Create a command object. First and second word must be supplied, but
- * either one (or both) can be null.
- * @param firstWord The first word of the command. Null if the command
- * was not recognised.
- * @param secondWord The second word of the command.
- */
- public Command(String firstWord, String secondWord)
- {
- commandWord = firstWord;
- this.secondWord = secondWord;
- }
- /**
- * Return the command word (the first word) of this command. If the
- * command was not understood, the result is null.
- * @return The command word.
- */
- public String getCommandWord()
- {
- return commandWord;
- }
- /**
- * @return The second word of this command. Returns null if there was no
- * second word.
- */
- public String getSecondWord()
- {
- return secondWord;
- }
- /**
- * @return true if this command was not understood.
- */
- public boolean isUnknown()
- {
- return (commandWord == null);
- }
- /**
- * @return true if the command has a second word.
- */
- public boolean hasSecondWord()
- {
- return (secondWord != null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement