Skip to content

Commit 081fe4e

Browse files
authored
Merge pull request #2 from andrea-twl/branch-A-Assertions
A-Assertions
2 parents b5e8f0f + a61b6df commit 081fe4e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/main/java/Parser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ String parseGeneralCommand(String input) throws DukeIncompleteCommandException {
7171
return taskList.listString();
7272
} else if (input.contains("done")) {
7373
inputs = input.split(" ");
74+
assert (inputs[1] != "") : "No index found!";
7475
index = Integer.parseInt(inputs[1]) - 1;
7576
return taskList.markDone(index);
7677
} else if (input.contains("delete")) {
7778
inputs = input.split(" ");
79+
assert (inputs[1] != "") : "No index found!";
7880
index = Integer.parseInt(inputs[1]) - 1;
7981
return taskList.delete(index);
8082
} else {
8183
inputs = input.split(" ");
84+
assert (inputs[1] != "") : "No index found!";
8285
String keyword = inputs[1];
8386
return taskList.find(keyword);
8487
}
@@ -97,6 +100,7 @@ public static Task parseAddTaskCommand(String input) throws DukeIncompleteComman
97100
TimedTask timedTask = new TimedTask();
98101
String editedInput;
99102
String regex;
103+
assert (input.contains(" ") : "Space between command and task needed!";
100104
if (input.contains("todo")) {
101105
editedInput = input.substring(4).trim();
102106
regex = "";

0 commit comments

Comments
 (0)