forked from lukovka08/Laba-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
224 lines (222 loc) · 7.35 KB
/
main.cpp
File metadata and controls
224 lines (222 loc) · 7.35 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
#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;
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 <<"---------------------------------------"<<endl;
cout <<"Your courier database name right now is: "<< courierfile<<endl;
cout <<"Your order database name right now is: "<< orderfile<<endl;
cout <<"Press 42- to see help"<<endl;
cout <<"---------------------------------------"<<endl;
cin >> n;
oselect(courierfile, orderfile);//функция распределения заказов по курьерам, работает автоматически каждую итерацию
switch (n){
case 42://справка
cout <<"---------------Press:---------------"<<endl;
cout <<"0- to start time"<<endl;
cout <<"1- to start work with couriers"<<endl;
cout <<"2- to start work with orders"<<endl;
cout <<"3- to show courier list"<<endl;
cout <<"4- to show order list"<<endl;
cout <<"100- to end up program"<<endl;
break;
case 0://промотать время вперед на n минут
runtime(courierfile, orderfile);
break;
case 100://конец программы
k=1;
cout<<"\( ̄▽ ̄)/ (*¯︶¯*) \(^▽^)/ Thank you, see you soon\( ̄▽ ̄)/ (*¯︶¯*) \(^▽^)/"<<endl;
break;
case 3://вывод всех курьеров
allcourierwrite(courierfile);
break;
case 4://вывод всех заказов
allorderwrite(orderfile);
break;
case 1://работа с курьерами
l=0;
system("cls");//переход на новую страницу
while(l==0){//меню раоботы с курьерами
cout <<"---------------------------------------"<<endl;
cout <<"Your courier database name right now is: "<< courierfile<<endl;
cout <<"Your order database name right now is: "<< orderfile<<endl;
cout <<"Press 42- to see help"<<endl;
cin>>m;
oselect(courierfile, orderfile);//распределение заказов по курьерам
switch (m){
case 42://справка
cout <<"---------------Press:---------------"<<endl;
cout <<"1- to add courier"<<endl;
cout <<"2- to fire courier"<<endl;
cout <<"3- to find courier with id"<<endl;
cout <<"4- to find courier by his name"<<endl;
cout <<"5- to find courier by his phone"<<endl;
cout <<"6- to show courier list"<<endl;
cout <<"7- to clear courier list"<<endl;
cout <<"99- to change courier database"<<endl;
cout <<"0- to return to main menu"<<endl;
break;
case 0://выход в главное меню
l=1;
break;
case 1://добавить курьера
addcourier(courierfile);
break;
case 2://удалить курьера
courierdeleting(courierfile, orderfile);
break;
case 3://найти курьера по id
csearchid(courierfile);
break;
case 4://найти по имени
csearchname(courierfile);
break;
case 5://найти по телефону
csearchphone(courierfile);
break;
case 6://вывести список курьеров
allcourierwrite(courierfile);
break;
case 7://очистить список курьеров
allcourierclear(courierfile, orderfile);
break;
case 99://смена базы данных курьеров(аналогично первой)
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;
}
}
system("cls");//переход на новую страницу
break;
case 2://работа с заказами
l=0;
system("cls");//новая страница
while(l==0){
cout <<"---------------------------------------"<<endl;
cout <<"Your courier database name right now is: "<< courierfile<<endl;
cout <<"Your order database name right now is: "<< orderfile<<endl;
cout <<"Press 42- to see help"<<endl;
oselect(courierfile, orderfile);//распределение заказов
cin>>m;
switch (m){
case 42://справка
cout <<"1- to add order"<<endl;
cout <<"2- to find order with id"<<endl;
cout <<"3- to show order list"<<endl;
cout <<"4- to clear order list"<<endl;
cout <<"99- to change order database"<<endl;
cout <<"0- to do to the main menu"<<endl;
break;
case 0://в главное меню
l=1;
break;
case 1://добавить заказ
addorder(orderfile);
break;
case 2://найти по id
osearchid(orderfile);
break;
case 3://вывести список заказов
allorderwrite(orderfile);
break;
case 4://очистить файл заказов
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;
}
}
system("cls");
break;
default://неправильный ввод
cout<<"You uncorrect data. Please, try again"<<endl;
break;
}
}
return 0;
}