-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
93 lines (76 loc) · 2.19 KB
/
main.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
/*
Programmer: Cameron Falls
File: main.cpp
Purpose: This file contains the program main.
*/
#include <iostream>
#include <vector>
#include "source/FileManagement.h"
#include "source/ListManagement.h"
#include "source/MenuManagement.h"
#include "source/TaskGroup.h"
#include "source/TaskManagement.h"
using namespace std;
int main()
{
const int LINE_LENGTH = 255;
vector<TaskGroup> groups;
int listChoice = 0; // selected list
int taskOption = 0; // selected menu option for tasks
int taskChoice = 0; // selected task from a list
loadLists(groups);
do // main loop, while quit is not selected
{
listChoice = 0;
taskOption = 0;
taskChoice = 0;
do // Selecting a list
{
listChoice = menuLists(groups);
cin.ignore(LINE_LENGTH, '\n');
if (listChoice < 0 || listChoice > (groups.size() + 1))
cout << "\nINVALID INPUT: Please try again." << endl;
} while (listChoice < 0 || listChoice > (groups.size() + 1));
cout << endl;
if (listChoice < groups.size()) // existing list
{
taskOption = menuTasks(groups[listChoice]);
cin.ignore(LINE_LENGTH, '\n');
switch (taskOption)
{
case 1: // edit task
taskChoice = menuChooseTask(groups[listChoice]);
if(taskChoice != groups[listChoice].getNumTasks())
editTask(groups[listChoice].getTask(taskChoice));
break;
case 2: // add task
addTask(groups[listChoice]);
break;
case 3: // remove task
removeTask(groups[listChoice]);
break;
case 4: // change list name
changeListName(groups, groups[listChoice]);
break;
case 5: // delete list
if (confirmDelete(groups[listChoice].getName()))
{
groups[listChoice].deleteList();
groups.erase(groups.begin() + listChoice);
}
break;
default: // go back (case 6)
break;
}
}
else if (listChoice == (groups.size())) // create new list
{
createNewList(groups);
}
for (TaskGroup t : groups) // save all lists
{
t.saveList();
}
} while (listChoice != (groups.size() + 1));
return 0;
}