33import java .io .File ;
44import java .io .IOException ;
55
6+ import duke .command .Command ;
7+ import duke .command .CommandResult ;
8+ import duke .exceptions .DukeCommandParseException ;
69import duke .exceptions .DukeDateParseException ;
710import duke .exceptions .DukeOutOfBoundsException ;
8- import duke .exceptions .DukeCommandParseException ;
911import duke .exceptions .DukeStorageException ;
1012import duke .model .TaskList ;
1113import duke .parser .CommandParser ;
1214import duke .storage .Storage ;
1315import duke .ui .MessageGenerator ;
14- import duke .command .Command ;
15- import duke .command .CommandResult ;
16+
1617
1718/**
1819 * main class containing the Duke Chatbot main logic.
1920 */
2021
2122public class Duke {
2223
23- private final static String STORAGE_DIRECTORY_PATH = "data" ;
24- private final static String STORAGE_FILE_PATH = "data/duke.txt" ;
25- private final static String STORAGE_INITIALIZATION_ERROR_MESSAGE = "Cannot Crete file duke.txt" ;
24+ private static final String STORAGE_DIRECTORY_PATH = "data" ;
25+ private static final String STORAGE_FILE_PATH = "data/duke.txt" ;
26+ private static final String STORAGE_INITIALIZATION_ERROR_MESSAGE = "Cannot Crete file duke.txt" ;
2627
2728 private static Storage storage ;
2829 private MessageGenerator messageGenerator ;
2930 private TaskList tasks ;
3031 private boolean isExit = false ;
3132
3233
34+ /**
35+ * Initializes and loads all the data from storage, as well as create the nexessary classes.
36+ *
37+ * @throws IOException when the file does not exist and Duke cannot create the file in the necessary path
38+ */
39+
3340 public Duke () throws IOException {
3441 this .messageGenerator = new MessageGenerator ();
3542 Duke .storage = initializeStorage ();
@@ -62,12 +69,22 @@ private Storage initializeStorage() throws IOException {
6269 return new Storage ("data/duke.txt" );
6370 }
6471
72+ /**
73+ * Returns the message to display at the start of the program.
74+ *
75+ * @return the message to display at the when Duke is started.
76+ */
6577
66-
67- public String startMessage (){
78+ public String startMessage () {
6879 return messageGenerator .getWelcomeMessage ();
6980 }
7081
82+ /**
83+ * Runs the Duke logic given the input string and gets Duke's response to the input.
84+ *
85+ * @param input the string to be passed to Dyke
86+ * @return the response after Duke analyses the string
87+ */
7188
7289 public String getResponse (String input ) {
7390 try {
@@ -85,6 +102,13 @@ public String getResponse(String input) {
85102 }
86103 }
87104
105+ /**
106+ * Gets the exit flag for Duke Chatbot
107+ * @return the flag isExit. It is true if the exit Command has been executed.
108+ * Else it will be false to show Duke is still running
109+ *
110+ */
111+
88112 public boolean getIsExit () {
89113 return isExit ;
90114 }
0 commit comments