-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
49 lines (45 loc) · 1.72 KB
/
Main.java
File metadata and controls
49 lines (45 loc) · 1.72 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ToDoList toDoList = new ToDoList();
Scanner scanner = new Scanner(System.in);
int choice;
do {
System.out.println("\n--- To-Do List Menu ---");
System.out.println("1. Add Task");
System.out.println("2. View Tasks");
System.out.println("3. Mark Task as Done");
System.out.println("4. Remove Task");
System.out.println("5. Exit");
System.out.print("Enter your choice: ");
choice = scanner.nextInt();
scanner.nextLine(); // consume newline
switch (choice) {
case 1:
System.out.print("Enter task description: ");
String description = scanner.nextLine();
toDoList.addTask(description);
break;
case 2:
toDoList.listTasks();
break;
case 3:
System.out.print("Enter task id to mark as done: ");
int doneId = scanner.nextInt();
toDoList.markTaskCompleted(doneId);
break;
case 4:
System.out.print("Enter task id to remove: ");
int removeId = scanner.nextInt();
toDoList.removeTask(removeId);
break;
case 5:
System.out.println("Exiting... Goodbye!");
break;
default:
System.out.println("Invalid choice. Try again.");
}
} while (choice != 5);
scanner.close();
}
}