Repository navigation
Expand file tree
/
Copy pathmenu.cpp
More file actions
139 lines (123 loc) · 3.15 KB
/
Copy pathmenu.cpp
File metadata and controls
139 lines (123 loc) · 3.15 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
#include <iostream>
#include "sqlite3.h"
#include <stdio.h>
#include "menu.h"
using namespace std;
bool executeSQL(string executeString)
{
sqlite3* DB;
char* messageError;
int exit = sqlite3_open("tasks.db", &DB);
if (exit)
{
sqlite3_close(DB);
return false;
}
else
{
string sql(executeString);
exit = sqlite3_exec(DB, sql.c_str(), NULL, 0, &messageError);
if (exit != SQLITE_OK)
{
sqlite3_free(messageError);
sqlite3_close(DB);
return false;
}
else
{
sqlite3_close(DB);
return true;
}
}
}
string getUserInput()
{
cout << ">>>>";
string userCommand;
cin >> userCommand;
for (char &c : userCommand) // convert whole cmd to lowercase
c = tolower(c);
return userCommand;
}
void addTask(string taskDescription, string taskPriority, string dueDate)
{
}
void deleteTask(string idNumber)
{
}
void editTask(string idNumber)
{
}
void printTaskList(string sortingType)
{
}
void Menu()
{
string userCommand = getUserInput();
while (userCommand != "quit")
{
if (userCommand == "help")
{
cout << "===== Command List: =====" << endl;
cout << "'help' - view command list" << endl;
cout << "'task' - begin a task command sequence" << endl;
}
else if (userCommand == "task")
{
cout << "Task Menu: would you like to add, delete, or print tasks?" << endl;
cout << "Enter 'add', 'delete' or 'print' to continue..." << endl;
userCommand = getUserInput();
if (userCommand == "add")
{
string taskDescription, taskPriority, dueDate;
cout << "Give a description for this task: ";
cin >> taskDescription;
cout << "What priority does this task have?" << endl;
cout << "Enter 'high', 'medium', 'low', or 'none': ";
cin >> taskPriority;
cout << "What date should this task be completed before?" << endl;
cout << "Enter a date in format XX/XX/XXXX (i.e 01/01/2000), or 'none' for no due-date: ";
cin >> dueDate;
addTask(taskDescription, taskPriority, dueDate);
printTaskList("priority");
}
else if (userCommand == "delete")
{
string idNumber;
printTaskList("idAsc");
cout << "Which task would you like to delete? (enter ID number from above list): ";
cin >> idNumber;
deleteTask(idNumber);
}
else if (userCommand == "edit")
{
string idNumber;
printTaskList("idAsc");
cout << "Which task would you like to edit? (enter ID number from above list): ";
cin >> idNumber;
editTask(idNumber);
}
else if (userCommand == "print")
{
string sortingType;
cout << "Enter sorting type from below list:" << endl;
cout << "'priority' - sort by task priority" << endl;
cout << "'id' - sort by the ID number of the task" << endl;
cout << "'dateOldest' - sort by due date showing the oldest " << endl;
cout << endl;
cout << "Enter 'priority', 'id', 'dateOldest', or 'dateNewest': ";
cin >> sortingType;
printTaskList(sortingType);
}
else // catch
{
cout << "Incorrect command, '" << userCommand << "', please try again..." << endl;
}
}
else // catch
{
cout << "Incorrect command, '" << userCommand << "' please try again..." << endl;
}
userCommand = getUserInput(); // get next user command
}
}