-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
144 lines (139 loc) · 3.49 KB
/
main.cpp
File metadata and controls
144 lines (139 loc) · 3.49 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
#include <iostream>
#include <fstream>
#include <string>
#include <clocale>
#include "clas.hpp"
using namespace std;
int main(int ac, char *argv[]) {
int i,n,k;
if (argc <= 2) {
cout << "Не заданы имена файлов" << endl;
return 0;
}
food foo;
drink dr;
ifstream f(argv[1]);
ifstream d(argv[2]);
if (!f.is_open() & d.is_open()) {
cout << "Ошибка открытия файлов" << endl;
return 0;
}
f>>n;
shop* df2 = new shop[n];
for (int i=0;i<n;i++){
f>>foo;
df2[i].foo=foo;
}
d>>k;
for (int i=0;i<k;i++){
d>>dr;
df2[i].dr=dr;
}
f.close();
d.close();
SetLocale(LC_ALL, "Rus");
int b;
for(;;){
system("clear");
cout<<"Выберите одну из команд:"<<endl;
cout<<"1-Посмотреть арсенал магазина"<<endl;
cout<<"2-Посмотреть информацию о конкретном товаре"<<endl;
cout<<"3-Добавить товар на склад"<<endl;
cout<<"4-Удалить товар со склада"<<endl;
cout<<"5-Изменить информацию о товаре" << endl;
cout<<"6-Выход"<<endl;
cin>>b;
while (b==1){
system("clear");
cout<<"Еда"<<endl;
for (int i=0;i<n;i++){
cout<<df2[i].foo;
}
cout<<"Напитки"<<endl;
for (int i=0;i<k;i++){
cout<<df2[i].dr;
}
cout<<"1-Посмотреть еще раз"<<endl;
cout<<"0-Вернуться назад"<<endl;
cin>>b;
}
while (b==2){
system("clear");
cout<<"Введите 1 если напиток, 0-если еда\n";
int h;
cin>>h;
if (h==0){
string name;
cin>> name;
print_food(df2, n,name);
}
else{
string name;
cin>>name;
print_drink(df2, k,name);
}
cout<<"2-Посмотреть ещё раз"<<endl;
cout<<"0-Вернуться назад"<<endl;
cin>>b;
}
while (b==3){
system("clear");
cout<<"Введите 1 если напиток, 0-если еда\n";
int h;
cin>>h;
if (h==0){
push_food(df2,n,k);
}
else{
push_drink(df2,n,k);
}
cout<<"3-добавить ещё товар:\n";
cout<<"0-Вернуться назад:\n";
cin>>b;
}
while (b==4){
system("clear");
cout<<"Введите 1 если напиток, 0-если еда\n";
int h;
cin>>h;
if (h==0){
delete_food(df2,n,k);
}
else{
delete_drink(df2,n,k);
}
cout<<"4-Удалить еще один продукт\n";
cout<<"0-Вернуться назад\n";
cin>>b;
}
if (b == 5) {
system("clear");
cout<< "Введите 1 если напиток, 0-если еда\n";
int h;
cin >> h;
if (h == 0) {
fix_food(df2, n, k);
}
else {
fix_drink(dd2, n, k);
}
cout << "5-Изменить ещё один продукт" << endl;
cout << "0-Вернуться назад" << endl;
cin >> b;
}
if (b==6){
system("clear");
ofstream f(argv[1], ios_base::trunc);
ofstream d(argv[2], ios_base::trunc);
f<<n<<endl;
for (int i=0;i<n;i++)
f<<df2[i].foo;
d<<k<<endl;
for (int i=0;i<k;i++)
d<<df2[i].dr;
f.close();
d.close();
return 0;
}
}
}