-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.cc
139 lines (123 loc) · 3.69 KB
/
program.cc
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
#include "Warehouse.hh"
#include "Inventory.hh"
using namespace std;
void poner_prod(inventory& inv){
string product;
cin>>product;
cout<<"poner_prod "<<product<<endl;
if(inv.exists(product)) cout<<" error"<<endl;
else inv.poner_prod(product);
}
void quitar_prod(inventory& inv){
string product;
cin>>product;
cout<<"quitar_prod "<<product<<endl; //producto tiene que ser cero cantidad
if(inv.exists(product) and inv.consultar_prod(product)==0) inv.quitar_prod(product);
else cout<<" error"<<endl;
}
void poner_items(warehouse& a, inventory& i){
int sala;
string product;
int quantity;
cin>>sala>>product>>quantity;
cout<<"poner_items "<<sala<<' '<<product<<' '<<quantity<<endl;
--sala;
if(i.exists(product) and a.exists(sala)) cout<<" "<<a.poner_items(sala, product, quantity, i)<<endl;
else cout<<" error"<<endl;
}
void quitar_items(warehouse& a, inventory& i){
int sala;
string product;
int quantity;
cin>>sala>>product>>quantity;
cout<<"quitar_items "<<sala<<' '<<product<<' '<<quantity<<endl;
--sala;
if(i.exists(product) and a.exists(sala)) cout<<" "<<a.quitar_items(sala, product, quantity, i)<<endl;
else cout<<" error"<<endl;
}
void distribuir(warehouse& w, inventory& i){
string product;
int quantity;
cin>>product>>quantity;
cout<<"distribuir "<<product<<' '<<quantity<<endl;
if(i.exists(product)){
cout<<" "<<warehouse::distribuir(product, quantity, i, w)<<endl;
//cout<<quantity<<endl;
}
else cout<<" error"<<endl;
}
void compactar(warehouse& a){
int sala;
cin>>sala;
cout<<"compactar "<<sala<<endl;
--sala;
if(a.exists(sala)) a.compactar(sala);
else cout<<" error"<<endl;
}
void reorganizar(warehouse& a){
int sala;
cin>>sala;
cout<<"reorganizar "<<sala<<endl;
--sala;
if(a.exists(sala)) a.reorganizar(sala);
else cout<<" error"<<endl;
}
void redimensionar(warehouse& a){
int sala, files, columnes;
cin>>sala>>files>>columnes;
cout<<"redimensionar "<<sala<<' '<<files<<' '<<columnes<<endl;
--sala;
if(a.exists(sala) and a.sala_redimensionable(sala, files, columnes)) a.redimensionar(sala, files, columnes);
else cout<<" error"<<endl;
}
void inventario(const inventory& i){
cout<<"inventario"<<endl;
i.inventario();
}
void escribir(const warehouse& a){
int sala;
cin>>sala;
cout<<"escribir "<<sala<<endl;
--sala;
if(a.exists(sala)) a.escribir(sala);
else cout<<"error"<<endl;
}
void consultar_pos(warehouse& a){
int sala, fila, columna; //const MIRAR
cin>>sala>>fila>>columna;
cout<<"consultar_pos "<<sala<<' '<<fila<<' '<<columna<<endl;
--sala;
--fila; --columna;
if(a.exists(sala) and a.pos_valid(sala, fila, columna)) cout<<" "<<a.consultar_pos(sala, fila, columna)<<endl;
else cout<<" error"<<endl;
}
void consultar_prod(const inventory& inv){
string product;
cin>>product;
cout<<"consultar_prod "<<product<<endl;
if(inv.exists(product)) cout<<" "<<inv.consultar_prod(product)<<endl;
else cout<<" error"<<endl;
}
int main(){
warehouse almacen;
int n_sales;
cin>>n_sales;
almacen.specify(n_sales);
inventory inv;
string option;
while(cin>>option and option!="fin"){
if(option=="poner_prod") poner_prod(inv);
else if(option=="quitar_prod") quitar_prod(inv);
else if(option=="poner_items") poner_items(almacen, inv);
else if(option=="quitar_items") quitar_items(almacen, inv);
else if(option=="distribuir") distribuir(almacen, inv);
else if(option=="compactar") compactar(almacen);
else if(option=="reorganizar") reorganizar(almacen);
else if(option=="redimensionar") redimensionar(almacen);
else if(option=="inventario") inventario(inv);
else if(option=="escribir") escribir(almacen);
else if(option=="consultar_pos") consultar_pos(almacen);
else if(option=="consultar_prod") consultar_prod(inv);
}
cout<<"fin"<<endl;
}