diff --git a/data/duke.txt b/data/duke.txt index fa1502ebfd..e69de29bb2 100644 --- a/data/duke.txt +++ b/data/duke.txt @@ -1,6 +0,0 @@ -<<<<<<< HEAD -D|0|abc|2022-10-04T12:00 -======= -T|1|play -T|1|eat ->>>>>>> 214560c1796b2e9cd7580c42ade8f2d41082b479 diff --git a/src/main/java/Duke/Parser.java b/src/main/java/Duke/Parser.java index 1869b7e61d..f1c7525b6e 100644 --- a/src/main/java/Duke/Parser.java +++ b/src/main/java/Duke/Parser.java @@ -33,10 +33,12 @@ public static void readLine(Ui ui, String command, TaskList tasks, MainWindow ma } private static void markUnmarkTask(String[] strArr, TaskList tasks) { - assert java.util.regex.Pattern.matches("\\d+", strArr[1]) : "The 2nd parameter should be a " + - "positive integer"; + assert java.util.regex.Pattern.matches("\\d+", strArr[1]) : "The 2nd parameter should be a " + + "positive integer"; int index = Integer.parseInt(strArr[1]) - 1; - assert index < tasks.getSize() : "the index to be mark or unmark should be less than " + tasks.getSize(); + assert index != -1 : "the 2nd parameter should start from index 1"; + assert index < tasks.getSize() : "the 2nd parameter to be mark or unmark should be less than or equals to " + + tasks.getSize(); if (strArr[0].equals("mark")) { tasks.markTaskAsDone(index); } else if (strArr[0].equals("unmark")) { @@ -45,10 +47,11 @@ private static void markUnmarkTask(String[] strArr, TaskList tasks) { } private static void deleteTask(String[] strArr, TaskList tasks) { - assert java.util.regex.Pattern.matches("\\d+", strArr[1]) : "The 2nd parameter should be a " + - "positive integer"; + assert java.util.regex.Pattern.matches("\\d+", strArr[1]) : "The 2nd parameter should be a " + + "positive integer"; int index = Integer.parseInt(strArr[1]) - 1; - assert index < tasks.getSize() : "the index to be deleted should be less than " + tasks.getSize(); + assert index != -1 : "the 2nd parameter should start from index 1"; + assert index < tasks.getSize() : "the 2nd parameter should be less than or equals to " + tasks.getSize(); tasks.deleteTask(index); }