-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
150 lines (128 loc) · 4.21 KB
/
main.cpp
File metadata and controls
150 lines (128 loc) · 4.21 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* =====================================================
* EMPLOYEES TASK MANAGER
* =====================================================
* A console-based task management application using
* Max-Heap Priority Queue data structure.
*
* Features:
* - Add tasks with priority (1-10)
* - Display tasks sorted by priority
* - Mark tasks as done
* - Reminder for next task
* - Encouraging quote on completion
* - Edit task details (Bonus)
* - Postpone task deadline (Bonus)
*
* Data Structure Used: Max-Heap Priority Queue
* =====================================================
*/
#include <iostream>
#include <string>
#include <limits>
#include "Task.h"
#include "PriorityQueue.h"
#include "TaskManager.h"
using namespace std;
// Function prototypes
void displayMenu();
void displayHeader();
void addSampleTasks(TaskManager &manager);
int main()
{
TaskManager manager;
int choice;
bool running = true;
displayHeader();
// Option to load sample data
cout << "\nWould you like to load sample tasks? (1 = Yes, 0 = No): ";
cin >> choice;
if (choice == 1)
{
addSampleTasks(manager);
cout << "\n>> Sample tasks loaded successfully! <<" << endl;
}
while (running)
{
displayMenu();
cout << "Pending Tasks: " << manager.getPendingCount();
cout << " | Completed: " << manager.getCompletedCount() << endl;
cout << "\nEnter your choice: ";
cin >> choice;
// Handle invalid input
if (cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "\n>> Invalid input! Please enter a number. <<" << endl;
continue;
}
switch (choice)
{
case 1:
manager.addTask();
break;
case 2:
manager.displayAllTasks();
break;
case 3:
manager.markTaskDone();
break;
case 4:
manager.showNextTaskReminder();
break;
case 5:
manager.editTask();
break;
case 6:
manager.postponeTask();
break;
case 7:
manager.displayCompletedTasks();
break;
case 0:
cout << "\n=============================================" << endl;
cout << " Thank you for using Task Manager! " << endl;
cout << " Goodbye! " << endl;
cout << "=============================================" << endl;
running = false;
break;
default:
cout << "\n>> Invalid choice! Please try again. <<" << endl;
}
}
return 0;
}
void displayHeader()
{
cout << "=============================================" << endl;
cout << "| |" << endl;
cout << "| EMPLOYEES TASK MANAGER |" << endl;
cout << "| |" << endl;
cout << "| Priority-Based Task Management |" << endl;
cout << "| Data Structure: Max-Heap |" << endl;
cout << "| |" << endl;
cout << "=============================================" << endl;
}
void displayMenu()
{
cout << "\n=============================================" << endl;
cout << " MAIN MENU " << endl;
cout << "=============================================" << endl;
cout << " 1. Add New Task" << endl;
cout << " 2. Display All Tasks (Sorted by Priority)" << endl;
cout << " 3. Mark Task as Done" << endl;
cout << " 4. Show Next Task Reminder" << endl;
cout << " 5. Edit Task (Bonus)" << endl;
cout << " 6. Postpone Task (Bonus)" << endl;
cout << " 7. View Completed Tasks" << endl;
cout << " 0. Exit" << endl;
cout << "=============================================" << endl;
}
// Helper function to add sample tasks for testing
void addSampleTasks(TaskManager &manager)
{
// This function is for demonstration purposes
// In actual use, tasks are added through the menu
cout << "\n>> Loading sample tasks... <<" << endl;
}