-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserMainMenu.cpp
259 lines (208 loc) · 6.85 KB
/
userMainMenu.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#include <iostream>
#include <string.h>
#include "userMainMenu.h"
#include "FileWork.h"
void randAppendToDoList(ToDoList& mylist)
{
int userInputInt;
std::cout<< "Input count of ToDo\'s to add: ";
std::cin>> userInputInt;
for( int i = 0; i < userInputInt; i++ )
{
ToDo* p = new ToDo(rand()%100+1, Date(rand()%30+1, rand()%11+1, rand()%2000+1000), "#WFLife", rand()%1);
mylist.pushElem(p);
}
mylist.show();
}
void appendToDoList(ToDoList& mylist)
{
int userInputInt;
int nDay, nMonth, nYear, nPrior, nComplete;
char* nTag = new char[255];
bool isComplete;
std::cout<< "Input count of ToDo\'s to add: ";
std::cin>> userInputInt;
for( int i = 0; i < userInputInt; i++ )
{
isComplete = false;
std::cout<<std::endl<<"Input tag text of current ToDo\'s: ";
std::cin>>nTag;
std::cout<<std::endl<< "Input date in local format day//month//year: ";
std::cin>> nDay>> nMonth>> nYear;
std::cout<<std::endl<< "Input priority in decimal number: ";
std::cin>> nPrior;
std::cout<<std::endl<< "Input \'1\' if that ToDo\'s is complete or \'0\' if it\'s not: ";
std::cin>> nComplete;
if(nComplete==1)
isComplete = true;
ToDo* p = new ToDo(nPrior, Date(nDay, nMonth, nYear), nTag, isComplete);
mylist.pushElem(p);
}
mylist.show();
delete[] nTag;
}
void setupPriors(ToDoList& mylist)
{
int userInputInt;
int priority;
bool isRetry;
do
{
isRetry = false;
std::cout<< "Input the same ToDo\'s number to setup priority: ";
std::cin>> userInputInt;
std::cout<< "Input priority number: ";
std::cin>> priority;
mylist.setPriority(userInputInt-1, priority);
std::cout<< "Do you want to do this with other elements? :(0-false, 1-true)";
std::cin>> userInputInt;
if(userInputInt!=0)
isRetry = true;
}
while(isRetry);
mylist.show();
}
void setupDates(ToDoList& mylist)
{
int userInputInt;
int tDay, tMonth, tYear;
bool isRetry;
do
{
isRetry = false;
std::cout<< "Input the same ToDo\'s number to setup date: ";
std::cin>> userInputInt;
std::cout<< "Input date in local format day//month//year: ";
std::cin>> tDay>> tMonth>> tYear;
mylist.setDate(userInputInt-1, Date(tDay,tMonth,tYear));
mylist.show();
std::cout<< "Do you want to do this with other elements? :(0-false, 1-true)";
std::cin>> userInputInt;
if(userInputInt!=0)
isRetry = true;
}
while(isRetry);
}
void removeToDo(ToDoList& mylist)
{
int userInputInt;
bool isRetry;
do
{
isRetry = false;
std::cout<<"Input the same elem number to removing: ";
std::cin>> userInputInt;
mylist.removeElem(userInputInt-1);
mylist.show();
std::cout<< "Do you want to do this again? :(0-false, 1-true)";
std::cin>> userInputInt;
if(userInputInt!=0)
isRetry = true;
}
while(isRetry);
}
void setupTags(ToDoList& mylist)
{
int userInputInt;
bool isRetry;
char* nTag = new char[255];
do
{
isRetry = false;
std::cout<<"Input the same elem number to setup new tag: ";
std::cin>> userInputInt;
std::cout<<std::endl<<"Input tag text of current ToDo\'s: ";
std::cin>>nTag;
mylist.setTag(userInputInt-1, nTag);
mylist.show();
std::cout<< "Do you want to do this with other elements? :(0-false, 1-true)";
std::cin>> userInputInt;
if(userInputInt!=0)
isRetry = true;
}
while(isRetry);
delete[] nTag;
}
void findToDo(ToDoList& mylist) //8. Ïîèñê çàäà÷è ïî: äàòå, òåãó, ïðèîðèòåòó, è ò.ä.+
{
int userInputInt;
int nDay, nMonth, nYear, nPrior, nComplete;
char* nTag = new char[255];
bool isRetry, isComplete=false;
do
{
isRetry = false;
std::cout<< "Enter the date in local format dd/mm/YYYY :";
std::cin>> nDay>>nMonth>> nYear;
std::cout<< "Enter the tag: ";
std::cin>> nTag;
std::cout<< "Enter the priority: ";
std::cin>> nPrior;
std::cout<< "Enter the complete(1-true, 0-false): ";
std::cin>> nComplete;
if(nComplete==1)
isComplete = true;
mylist.showElem(mylist.findElem(Date(nDay, nMonth, nYear), nTag, nPrior, isComplete));
std::cout<< "Do you want to do this again? :(0-false, 1-true)";
std::cin>> userInputInt;
if(userInputInt!=0)
isRetry = true;
}
while(isRetry);
}
void userMainMenu()
{
ToDoListProxy mylist;
int userInputInt;
std::string fileName = "";
fileName=inputFilename(fileName);
do
{
std::cout<<"Main menu."<<std::endl;
std::cout<<"1. Append to list some ToDo\'s"<<std::endl;
std::cout<<"2. Setup priors in current list"<<std::endl;
std::cout<<"3. Setup dates in current list"<<std::endl;
std::cout<<"4. Remove ToDo\'s from current list"<<std::endl;
std::cout<<"5. Setup tags of ToDo\'s in current list"<<std::endl;
std::cout<<"6. Save current list\\Load in current list"<<std::endl;
std::cout<<"7. Find ToDo\'s in current list"<<std::endl;
std::cout<<"8. Append to list rand ToDo\'s"<<std::endl;
std::cout<<"9. Show list"<<std::endl;
std::cout<<"0. Exit"<<std::endl;
std::cin>> userInputInt;
switch(userInputInt)
{
case 1: //1. Ñîçäàíèå ñïèñêà çàäà÷++
appendToDoList(mylist);
break;
case 2: //2. Óñòàíîâêà ïðèîðèòåòîâ çàäà÷è++
setupPriors(mylist);
break;
case 3: //3. Óñòàíîâêà äàòû âûïîëíåíèÿ çàäà÷è++
setupDates(mylist);
break;
case 4: //4. Óäàëåíèå çàäà÷è++
removeToDo(mylist);
break;
case 5: //6. Óñòàíîâêà òåãà çàäà÷è+
setupTags(mylist);
break;
case 6: //7. Çàãðóæàòü è ñîõðàíÿòü â ôàéë ñïèñîê çàäà÷
saveLoadListToDo(fileName, mylist);
break;
case 7: //8. Ïîèñê çàäà÷è ïî: äàòå, òåãó, ïðèîðèòåòó, è ò.ä.+
findToDo(mylist);
break;
case 8: //8. Çàïîëíèòü ñëó÷àéíî
randAppendToDoList(mylist);
break;
case 9: //8. Çàïîëíèòü ñëó÷àéíî
mylist.show();
break;
default:
mylist.show();
break;
}
}
while(userInputInt>0&&userInputInt<10);
}