-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
148 lines (114 loc) · 2.45 KB
/
main.cpp
File metadata and controls
148 lines (114 loc) · 2.45 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
#include<iostream>
#include<list>
#include<iterator>
#include<stdlib.h>
#include "inc/taskHandler.h"
/*
to be done: remove from list when deleted
*/
std::list<taskHandler* > l;
void createNewElem()
{
//std::cout<<"here\n";
taskHandler *i = new taskHandler();
i->createTask();
l.push_back(i);
i++;
}
void readList()
{
int i = 1;
std::cout<<"\nTask Status...";
for(taskHandler *x:l)
{
x->displayTask();
std::cout<<"\nAlter task? (Press "<<i<<")\n";
i++;
}
std::cout<<"\nEnter 0 if you wish to alter no task!";
int choice = 0;
list_input:
std::cout<<"\nEnter your choice ";
try
{
std::cin>>choice;
std::cin.ignore();
if(choice < 0 || choice > i) throw(choice);
}
catch(int choice)
{
std::cout<<"Plz be reasonable in life";
goto list_input;
}
if(choice > 0)
{
int i=0;
for(taskHandler *x:l)
{
if(i == choice-1)
{
if(x->alterTask()) l.remove(x);
break;
}
i++;
}
/*
std::list<taskHandler* >::iterator it = l.begin();
std::advance(it, choice-1);
std::cout<<*it<<std::endl;
*/
}
}
int menuBar()
{
std::cout<<"\n----------------TO DO----------------\n\n";
std::cout<<"Create new Deadline: Press 1\n";
std::cout<<"See all Deadlines: Press 2\n";
std::cout<<"Exit: Press 0\n\n";
auto choice = 0;
input:
std::cout<<"Enter choice: ";
try
{
std::cin>>choice;
std::cin.ignore();
//std::string type = typeid(choice).name();
//std::cout<<type<<std::endl;
//this here needs dire ATTENTION
if(choice < 0 || choice > 2) throw choice;
}
catch(int wrong)
{
std::cout<<"Plz be reasonable in life\n";
goto input;
}
/*
catch(char wrong)
{
std::cout<<"Plz be reasonable in life\n";
goto input;
}
catch(char* wrong)
{
std::cout<<"Plz be reasonable in life\n";
goto input;
}
*/
//std::cout<<"here"<<choice<<"\n";
return choice;
}
int main()
{
//int res = menuBar();
while(1)
{
switch(menuBar())
{
case 1: createNewElem(); break;
case 2: readList(); break;
case 0: exit(86); break;
default: break;
}
}
return 0;
}