-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (50 loc) · 1.59 KB
/
main.cpp
File metadata and controls
57 lines (50 loc) · 1.59 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
#include <iostream>
#include <vector>
#include "Task.h" // Include the Task class
using namespace std;
int main() {
vector<Task> tasks;
int choice;
// Load tasks from file when program starts
Task::loadTasks(tasks);
do {
cout << "\n===== TO-DO LIST MANAGER =====\n";
cout << "1. ➕ Add Task\n";
cout << "2. 📋 View Tasks\n";
cout << "3. ✅ Mark Task as Completed\n";
cout << "4. 💾 Save & Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
string title, category;
cout << "Enter task title: ";
cin.ignore(); // Clear input buffer
getline(cin, title);
cout << "Enter category (optional): ";
getline(cin, category);
Task newTask(title, category);
tasks.push_back(newTask);
cout << "✅ Task added successfully!\n";
break;
}
case 2:
Task::viewTasks(tasks);
break;
case 3: {
int index;
cout << "Enter task number to mark as completed: ";
cin >> index;
Task::markCompleted(tasks, index);
break;
}
case 4:
Task::saveTasks(tasks);
cout << "💾 Tasks saved. Exiting...\n";
break;
default:
cout << "❌ Invalid choice, try again!\n";
}
} while (choice != 4);
return 0;
}