-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTaskManager.java
39 lines (32 loc) · 1.13 KB
/
TaskManager.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
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class TaskManager {
private Map<Task, LocalDateTime> completionTimes;
private Map<Task, String> notes;
public TaskManager() {
this.completionTimes = new HashMap<>();
this.notes = new HashMap<>();
}
public void addTask(Task task) {
completionTimes.put(task, null);
notes.put(task, "");
}
public void completeTask(Task task) {
// Update the completion time for the task
LocalDateTime completionTime = LocalDateTime.now();
completionTimes.put(task, completionTime);
// Gather notes from the user
Scanner scanner = new Scanner(System.in);
System.out.print("Enter notes for the completed task (press enter to skip): ");
String userNotes = scanner.nextLine();
notes.put(task, userNotes);
}
public LocalDateTime getCompletionTime(Task task) {
return completionTimes.get(task);
}
public String getNotes(Task task) {
return notes.get(task);
}
}