Skip to content

Commit

Permalink
Updated Commands and TaskList
Browse files Browse the repository at this point in the history
  • Loading branch information
nicljr committed Jan 31, 2023
1 parent 1d74e99 commit 8836d32
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/duke/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class TaskList {
num_tasks = 0;
}

public Integer getNumTasks() {
return num_tasks;
}

public Task markTask(int task_index) throws DukeException {
if (task_index > num_tasks || task_index < 1) {
throw new DukeException("There is no such task available\n");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/command/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public AddCommand(String textCmd) {
public void execute(Ui ui, Storage storage, TaskList taskList) throws DukeException {
Task to_add = taskAssigner.assignTask(textCmd);
taskList.add(to_add);
ui.printAddTask(to_add, taskList.num_tasks);
ui.printAddTask(to_add, taskList.getNumTasks());
}
}
2 changes: 1 addition & 1 deletion src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public DeleteCommand(String textCmd) {
public void execute(Ui ui, Storage storage, TaskList taskList) throws DukeException {
Task removedTask = taskList.deleteTask(
Parser.stringToInt(textCmd.substring(7)));
ui.printDeleteTask(removedTask, taskList.num_tasks);
ui.printDeleteTask(removedTask, taskList.getNumTasks());
}
}

0 comments on commit 8836d32

Please sign in to comment.