-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathAddTask.java
More file actions
26 lines (25 loc) · 872 Bytes
/
AddTask.java
File metadata and controls
26 lines (25 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.io.IOException;
public class AddTask extends Command{
private Task task;
private Tasks tasks;
private Ui ui;
private Storage storage;
/**
* Constructor for command for user to add a new task. Task can be either a normal task, an Event or a Deadline
* @param tasks list of existing tasks for task to be added to
* @param task Task to be added. Either be a normal task, an Event or a Deadline
* @param ui Handles interaction with the user
* @param storage updates "data/duke.txt"
*/
public AddTask(Tasks tasks, Task task, Ui ui, Storage storage) {
this.tasks = tasks;
this.task = task;
this.ui = ui;
this.storage = storage;
}
public void execute() throws IOException {
tasks.add(task);
ui.add(task, tasks);
storage.writeToFile(tasks);
}
}