-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTodo.java
More file actions
39 lines (33 loc) · 1.27 KB
/
Todo.java
File metadata and controls
39 lines (33 loc) · 1.27 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
import java.util.ArrayList;
import java.util.List;
public class TodoManager {
private List<Todo> todos;
public TodoManager() {
// Initial list of items (analogous to data.js)
this.todos = new ArrayList<>();
todos.add(new Todo(1, "Review new design mocks", false));
todos.add(new Todo(2, "Set up user research session for code prediction feature", false));
todos.add(new Todo(3, "Draft technical spec for new shopping cart API", true));
todos.add(new Todo(4, "Prepare performance review doc for 1:1 with Kate", false));
}
public List<Todo> getAllTodos() {
return todos;
}
public void toggleCompletion(int id) {
for (Todo todo : todos) {
if (todo.getId() == id) {
todo.setCompleted(!todo.isCompleted());
return;
}
}
}
public void displayTodos() {
System.out.println("\n--- To-Do List ---");
// Minor Task: The header display logic will go here
System.out.println("--- Tasks ---");
for (Todo todo : todos) {
System.out.println(todo);
// The display logic for the 'TodoItem' (including due date) is inside the Todo.toString() method in this simple setup
}
}
}