-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathTaskManagementSystemDemo.java
55 lines (44 loc) · 1.84 KB
/
TaskManagementSystemDemo.java
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
package taskmanagementsystem;
import java.util.Date;
import java.util.List;
public class TaskManagementSystemDemo {
public static void run() {
TaskManager taskManager = TaskManager.getInstance();
// Create users
User user1 = new User("1", "John Doe", "[email protected]");
User user2 = new User("2", "Jane Smith", "[email protected]");
// Create tasks
Task task1 = new Task("1", "Task 1", "Description 1", new Date(), 1, user1);
Task task2 = new Task("2", "Task 2", "Description 2", new Date(), 2, user2);
Task task3 = new Task("3", "Task 3", "Description 3", new Date(), 1, user1);
// Add tasks to the task manager
taskManager.createTask(task1);
taskManager.createTask(task2);
taskManager.createTask(task3);
// Update a task
task2.setDescription("Updated description");
taskManager.updateTask(task2);
// Search tasks
List<Task> searchResults = taskManager.searchTasks("Task");
System.out.println("Search Results:");
for (Task task : searchResults) {
System.out.println(task.getTitle());
}
// Filter tasks
List<Task> filteredTasks = taskManager.filterTasks(TaskStatus.PENDING, new Date(0), new Date(), 1);
System.out.println("Filtered Tasks:");
for (Task task : filteredTasks) {
System.out.println(task.getTitle());
}
// Mark a task as completed
taskManager.markTaskAsCompleted("1");
// Get task history for a user
List<Task> taskHistory = taskManager.getTaskHistory(user1);
System.out.println("Task History for " + user1.getName() + ":");
for (Task task : taskHistory) {
System.out.println(task.getTitle());
}
// Delete a task
taskManager.deleteTask("3");
}
}