/** * Kelas ini adalah kelas utama dari aplikasi "World of Zuul". * "World of Zuul" adalah game petualangan berbasis teks yang sangat sederhana. * * Kelas ini menyimpan informasi tentang perintah yang dikeluarkan oleh pengguna. * Perintah saat ini terdiri dari dua string: kata perintah dan kedua * kata (misalnya, jika perintahnya "take map", maka dua string * jelas adalah "take" dan "map"). * * Cara menggunakannya adalah: Perintah sudah diperiksa validitasnya * kata perintah. Jika pengguna memasukkan perintah yang tidak valid (kata yang tidak * Diketahui) maka kata perintahnya adalah . * * Jika perintah hanya memiliki satu kata, maka kata kedua adalah . * * @author Muhammad Bagus Istighfar * @version 0.1 - 17 November 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. The command word should be null to * indicate that this was a command that is not recognised by this game. * @param String firstWord * @param String secondWord */ 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 String commandWord */ public String getCommandWord() { return commandWord; } /** * Return the second word of this command. Returns null if there was no * second word. * @return String secondWord */ public String getSecondWord() { return secondWord; } /** * Return true if this command was not understood. * @return bool */ public boolean isUnknown() { return (commandWord == null); } /** * Return true if the command has a second word. * @return bool */ public boolean hasSecondWord() { return (secondWord != null); } }