Skip to content

Commit

Permalink
Handle out of bounds for mark/unmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-ruster committed Oct 3, 2023
1 parent 6f33548 commit 8d84f65
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/Task/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ public void delete(int j) {
* @param j Index of task. Index starts from 1.
*/
public void markTask(int j) {
try {
itemList.get(j - 1).setDone(true);

itemList.get(j - 1).setDone(true);

Ui.reportTaskMarked(itemList, j);
Ui.reportTaskMarked(itemList, j);
} catch (IndexOutOfBoundsException e) {
Ui.reportOutOfBounds();
}
}

/**
Expand All @@ -144,9 +147,13 @@ public void markTask(int j) {
* @param j Index of task. Index starts from 1.
*/
public void unmarkTask(int j) {
try{
itemList.get(j - 1).setDone(false);

Ui.reportTaskUnmarked(itemList, j);
} catch (IndexOutOfBoundsException e) {
Ui.reportOutOfBounds();
}
}

/**
Expand Down

0 comments on commit 8d84f65

Please sign in to comment.