-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManager.java
More file actions
68 lines (48 loc) · 1.33 KB
/
Manager.java
File metadata and controls
68 lines (48 loc) · 1.33 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package taskManager;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Iterator;
public class Manager {
private List<Task> tasks;
private int beginId;
public Manager() {
tasks = new ArrayList<>();
beginId = 1;
}
public void addTask(String title, String description, Date dueDate, String priority, String classCode, Boolean isFinished) {
Task newTask = new Task(beginId++, title, description, dueDate, priority, classCode, isFinished);
tasks.add(newTask);
}
public void editTask (int id, String title, String description, Date dueDate, String priority, String classCode, Boolean isFinished) {
Task task = taskId(id);
if (task != null) {
task.setTask(title);
task.setDesc(description);
task.setdueDate(dueDate);
task.setCode(classCode);
task.setIsFinished(isFinished);
}
}
public Task taskId(int id) {
for (Task task : tasks) {
if (task.getId() == id) {
return task;
}
}
return null;
}
public void deleteTask (int id) {
Iterator<Task> iterate = tasks.iterator();
while(iterate.hasNext()) {
Task task = iterate.next();
if (task.getId() == id) {
iterate.remove();
return;
}
}
}
public List<Task> listTasks() {
return tasks;
}
}