-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo list.cpp
61 lines (55 loc) · 1.7 KB
/
todo list.cpp
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
#include <iostream>
#include <queue>
#include <string>
using namespace std;
void displayTodoList(queue<string> &todoQueue) {
if (todoQueue.empty()) {
cout << "To do list is Empty." << endl;
} else {
cout << "To do List:" << endl;
int count = 1;
while (!todoQueue.empty()) {
cout << count << ". " << todoQueue.front() << endl;
todoQueue.pop();
count++;
}
}
}
int main() {
queue<string> todoQueue;
while (true) {
cout << "\nTo do List Menu:" << endl;
cout << "1. Add to do\n2. Remove To do\n3. Display To do List\n4. Exit\n";
cout << "Enter your choice: ";
int choice;
cin >> choice;
switch (choice) {
case 1: {
cout << "Enter to do item: ";
string todoItem;
cin.ignore();
getline(cin, todoItem);
todoQueue.push(todoItem);
cout << "Added Successfully." << endl;
break;
}
case 2: {
if (todoQueue.empty()) {
cout << "To do list is empty. There's nothing to remove." << endl;
} else {
cout << "Removing Item: " << todoQueue.front() << endl;
todoQueue.pop();
}
break;
}
case 3:
displayTodoList(todoQueue);
break;
case 4:
cout << "Exiting Program" << endl;
return 0;
default:
cout << "Invalid Choice, Choose again" << endl;
}
}
}