-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
224 lines (223 loc) · 6.85 KB
/
main.cpp
File metadata and controls
224 lines (223 loc) · 6.85 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
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
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include "classes.h"
using namespace std;
int main(){
string courierfile;
string orderfile;
cout << "Good morning."<<endl;//доброе утро
string s;
int n, m;
int k=0;
int l=0;
int y=0;
int x=0;
Courier cr;
Order od;
fstream fin;
while (k==0){//считываение имени файла с данными о курьерах
cout << "---------------Please enter new courier database name:(txt file!)- print '0' if you cant---------------"<<endl;
cin >> s;
if (s=="0"){//выход
cout<<" Thank you, see you later"<<endl;
exit(0);
}
courierfile=s;
fin.open(courierfile);
if(!fin.is_open()){//существует ли такой файл
cout <<"---------------Sorry, database can not be found. Please try again---------------"<<endl;
}
else{
cout<<"---------------Courier database changed sucsessfully---------------"<<endl;
k=1;
}
fin.close();
}
k=0;
while (k==0){//ввод базы данных для заказов
cout << "---------------Please enter new order database name:(txt file!)- print '0' if you cant---------------"<<endl;
cin >> s;
if (s=="0"){
cout<<"Great, see you later"<<endl;
exit(0);
}
s;
fin.open(s);
if(!fin.is_open()){//существует ли этот файл
cout <<"---------------Sorry, database can not be found. Please try again---------------"<<endl;
}
else{
cout<<"---------------Order database changed sucsessfully---------------"<<endl;
k=1;
orderfile=s;
}
fin.close();
}
int g;
k=0;
while (k==0){//главное меню
cout <<"Press 42- to see help"<<endl;
cout <<"---------------------------------------"<<endl;
cin >> n;
y=0;
for(y=0;y<25;y++){cout<<endl;}
y=0;
cr.oselect(courierfile, orderfile);//функция распределения заказов по курьерам, работает автоматически каждую итерацию
switch (n){
case 42://справка
cout <<"---------------Press:---------------"<<endl;
cout <<"0- to start time"<<endl;
cout <<"1- to show courier list"<<endl;
cout <<"2- to show order list"<<endl;
cout <<"10- to start work with couriers"<<endl;
cout <<"20- to start work with orders"<<endl;
cout <<"100- to end up program"<<endl;
break;
case 0://промотать время вперед на n минут
od.runtime(courierfile, orderfile);
break;
case 100://конец программы
k=1;
cout<<"\( ̄▽ ̄)/ (*¯︶¯*) \(^▽^)/ Thank you, see you soon\( ̄▽ ̄)/ (*¯︶¯*) \(^▽^)/"<<endl;
break;
case 1://вывод всех курьеров
cr.allcourierwrite(courierfile);
break;
case 2://вывод всех заказов
od.allorderwrite(orderfile);
break;
case 10://работа с курьерами
while(l==0){//меню раоботы с курьерами
cout <<"Press 42- to see help"<<endl;
cin>>m;
l=0;
for(l=0;l<25;l++){cout<<endl;}
l=0;
cr.oselect(courierfile, orderfile);//распределение заказов по курьерам
switch (m){
case 42://справка
cout <<"---------------Press:---------------"<<endl;
cout <<"1- to show courier list"<<endl;
cout <<"11- to add courier"<<endl;
cout <<"12- to fire courier"<<endl;
cout <<"13- to find courier with id"<<endl;
cout <<"14- to find courier by his name"<<endl;
cout <<"15- to find courier by his phone"<<endl;
cout <<"18- to clear courier list"<<endl;
cout <<"19- to change courier database"<<endl;
cout <<"100- to return to main menu"<<endl;
break;
case 1://вывести список курьеров
cr.allcourierwrite(courierfile);
break;
case 2://вывод всех заказов
od.allorderwrite(orderfile);
break;
case 100://выход в главное меню
l=1;
break;
case 11://добавить курьера
cr.addcourier(courierfile);
break;
case 12://удалить курьера
cr.courierdeleting(courierfile, orderfile);
break;
case 13://найти курьера по id
cr.csearchid(courierfile);
break;
case 14://найти по имени
cr.csearchname(courierfile);
break;
case 15://найти по телефону
cr.csearchphone(courierfile);
break;
case 18://очистить список курьеров
break;
case 19://смена базы данных курьеров(аналогично первой)
g=0;
while (g==0){
cout << "---------------Please enter new courier database name:(txt file!)- print '0' if you cant---------------"<<endl;
cin >> s;
if (s=="0"){
g==1;
}
fin.open(s);
if(!fin.is_open()){
cout <<"---------------Sorry, database can not be found. Please try again---------------"<<endl;
}
else{
cout<<"---------------Courier database changed sucsessfully---------------"<<endl;
g=1;
courierfile=s;
}
fin.close();
}
break;
}
}
break;
case 20://работа с заказами
x=0;
while(x==0){
cout <<"Press 42- to see help"<<endl;
cr.oselect(courierfile, orderfile);//распределение заказов
cin>>m;
l=0;
for(l=0;l<25;l++){cout<<endl;}
l=0;
switch (m){
case 42://справка
cout <<"21- to add order"<<endl;
cout <<"22- to find order with id"<<endl;
cout <<"23- to show order list"<<endl;
cout <<"24- to clear order list"<<endl;
cout <<"29- to change order database"<<endl;
cout <<"100- to do to the main menu"<<endl;
break;
case 100://в главное меню
x=1;
break;
case 21://добавить заказ
od.addorder(orderfile);
break;
case 22://найти по id
od.osearchid(orderfile);
break;
case 23://вывести список заказов
od.allorderwrite(orderfile);
break;
case 24://очистить файл заказов
cr.allorderclear(courierfile, orderfile);
break;
case 99://смена файла(аналогично начальной
g=0;
while (g==0){
cout << "---------------Please enter new order database name:(txt file!)- print '0' if you cant---------------"<<endl;
cin >> s;
if (s=="0"){
g==1;
}
fin.open(s);
if(!fin.is_open()){
cout <<"---------------Sorry, database can not be found. Please try again---------------"<<endl;
}
else{
cout<<"---------------Order database changed sucsessfully---------------"<<endl;
g=1;
orderfile=s;
}
fin.close();
}
break;
}
}
break;
default://неправильный ввод
cout<<"You uncorrect data. Please, try again"<<endl;
break;
}
}
return 0;
}