diff --git a/data/duke.txt b/data/duke.txt index 6eb77ab5b9..665a8492e1 100644 Binary files a/data/duke.txt and b/data/duke.txt differ diff --git a/src/main/java/monday/MainWindow.java b/src/main/java/monday/MainWindow.java index 16ab14d2ca..269da99bff 100644 --- a/src/main/java/monday/MainWindow.java +++ b/src/main/java/monday/MainWindow.java @@ -10,7 +10,6 @@ import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Duration; - import monday.monday.ui.Ui; /** @@ -31,6 +30,9 @@ public class MainWindow extends AnchorPane { private Image userImage = new Image(this.getClass().getResourceAsStream("/images/bai.png")); private Image mondayImage = new Image(this.getClass().getResourceAsStream("/images/fa.png")); + /** + * Start the programme and greets the user on start of program. + */ @FXML public void initialize() { dialogContainer.getChildren().add(DialogBox.getDukeDialog(Ui.greet(), mondayImage)); diff --git a/src/main/java/monday/Monday.java b/src/main/java/monday/Monday.java index 75e88bc7fe..15fa837d04 100644 --- a/src/main/java/monday/Monday.java +++ b/src/main/java/monday/Monday.java @@ -38,12 +38,6 @@ private void startMonday() { System.out.println(p.parseCommands(userInput)); } catch (MondayException e) { Ui.printErrorMessage("", e); - } catch (NumberFormatException e) { - Ui.printErrorMessage("Mark/UnMark number error: ", e); - } catch (IllegalArgumentException e) { - Ui.printErrorMessage("Argument Error: ", e); - } catch (IndexOutOfBoundsException e) { - Ui.printErrorMessage("Index out of Bound Error: ", e); } Ui.printSeparator(); } diff --git a/src/main/java/monday/monday/parser/Parser.java b/src/main/java/monday/monday/parser/Parser.java index 031ff5a2a8..02575372bf 100644 --- a/src/main/java/monday/monday/parser/Parser.java +++ b/src/main/java/monday/monday/parser/Parser.java @@ -161,7 +161,7 @@ private String deadLineCommand(String content) throws MondayException { return taskList.addToList(new Deadline(description.trim(), date.trim())); } catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Invalid Format. " + throw new MondayException("Invalid Format. " + "Usage: deadline (task) /by (time)"); } } @@ -190,7 +190,7 @@ private String eventCommand(String content) throws MondayException { start.trim(), end.trim())); } catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Invalid Format. " + throw new MondayException("Invalid Format. " + "Usage: event (task) /from (start time) /to (end time)"); } } @@ -229,7 +229,7 @@ private String findCommand(String content) throws MondayException { String[] keywordDetails = content.split(" "); if (keywordDetails.length > 1) { - throw new IllegalArgumentException("Invalid Format. " + throw new MondayException("Invalid Format. " + "Usage: find (keyword), there should only be one keyword."); } diff --git a/src/main/java/monday/task/TaskList.java b/src/main/java/monday/task/TaskList.java index c3418aa516..95fa5b4be4 100644 --- a/src/main/java/monday/task/TaskList.java +++ b/src/main/java/monday/task/TaskList.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.ArrayList; +import monday.monday.exception.MondayException; import monday.monday.ui.Ui; import monday.storage.TaskArrayListStorage; @@ -71,12 +72,12 @@ public String toString() { * * @param index The index of the task to be marked as done. * @return Message after marking the task as done. - * @throws IndexOutOfBoundsException If the index is out of range. + * @throws MondayException If the index is out of range. */ - public String mark(int index) { + public String mark(int index) throws MondayException { assert !tasks.isEmpty() : "Your task list is empty, please add more elements."; if (index < 1 || index > tasks.size()) { - throw new IndexOutOfBoundsException("Task index is out of range. " + throw new MondayException("Task index is out of range. " + "Check the number of tasks using the 'list' command."); } Task taskToEdit = tasks.get(index - 1); @@ -90,12 +91,12 @@ public String mark(int index) { * * @param index The index of the task to be marked as not done. * @return Message after marking the task as not done. - * @throws IndexOutOfBoundsException If the index is out of range. + * @throws MondayException If the index is out of range. */ - public String unMark(int index) { + public String unMark(int index) throws MondayException { assert !tasks.isEmpty() : "Your task list is empty, please add more elements."; if (index < 1 || index > tasks.size()) { - throw new IndexOutOfBoundsException("Task index is out of range. " + throw new MondayException("Task index is out of range. " + "Check the number of tasks using the 'list' command."); } Task taskToEdit = tasks.get(index - 1); @@ -109,12 +110,12 @@ public String unMark(int index) { * * @param index The index of the task to be deleted. * @return Message after deleting the task. - * @throws IndexOutOfBoundsException If the index is out of range. + * @throws MondayException If the index is out of range. */ - public String delete(int index) { + public String delete(int index) throws MondayException { assert !tasks.isEmpty() : "Your task list is empty, please add more elements."; if (index < 1 || index > tasks.size()) { - throw new IndexOutOfBoundsException("Task index is out of range. " + throw new MondayException("Task index is out of range. " + "Check the number of tasks using the 'list' command."); } Task taskToEdit = tasks.get(index - 1);