-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproducto.cpp
210 lines (180 loc) · 4.53 KB
/
producto.cpp
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
#include <string>
using namespace std;
class Producto
{
protected:
// Estandar
string id, categoria, nombre;
float precio;
int cantidad;
// Vestimenta
string talla, color, material;
// Jugueteria
bool es_educativo;
// Libreria
string autor, editorial;
// Ferreteria , Electronica
string tipo, marca, modelo;
public:
Producto(string _id = "", string _categoria = "", float _precio = 0.0, int _cantidad = 0, string _nombre = "")
{
id = _id;
precio = _precio;
nombre = _nombre;
categoria = _categoria;
cantidad = _cantidad;
}
// Estas funciones no se usan mas que para el primer inicio, pero se dejan por si acaso
void setDatosVestimenta(string _talla, string _color, string _material)
{
talla = _talla;
color = _color;
material = _material;
}
void setDatosElectronica(string _marca, string _modelo)
{
marca = _marca;
modelo = _modelo;
}
void setDatosFerreteria(string _tipo, string _marca, string _modelo)
{
tipo = _tipo;
marca = _marca;
modelo = _modelo;
}
void setDatosJuguetes(string _marca, bool _es_educativo)
{
marca = _marca;
es_educativo = _es_educativo;
}
void setDatosLibreria(string _autor, string _editorial)
{
autor = _autor;
editorial = _editorial;
}
// Setter
void setId(string _id)
{
id = _id;
}
void setMarca(string _marca)
{
marca = _marca;
}
void setPrecio(float _precio)
{
precio = _precio;
}
void setNombre(string _nombre)
{
nombre = _nombre;
}
void setCantidad(int _cantidad)
{
cantidad = _cantidad;
}
void setCategoria(string _categoria)
{
categoria = _categoria;
}
void setModelo(string _modelo)
{
modelo = _modelo;
}
void setAutor(string _autor)
{
autor = _autor;
}
void setEditorial(string _editorial)
{
editorial = _editorial;
}
void setEducativo(bool _es_educativo)
{
es_educativo = _es_educativo;
}
void setTalla(string _talla)
{
talla = _talla;
}
void setColor(string _color)
{
color = _color;
}
void setMaterial(string _material)
{
material = _material;
}
void setTipo(string _tipo)
{
tipo = _tipo;
}
// Getter
string getId()
{
return id;
}
float getPrecio()
{
return precio;
}
string getNombre()
{
return nombre;
}
int getCantidad()
{
return cantidad;
}
string getCategoria()
{
return categoria;
}
string getPrecioString()
{
return to_string(precio);
}
string getCantidadString()
{
return to_string(cantidad);
}
// Metodos
string esStringEducativo()
{
if (es_educativo == true)
{
return "Si";
}
else
{
return "No";
}
}
string getDatos()
{
if (categoria == "Vestimenta" || categoria == "vestimenta")
{
return id + " - " + categoria + " - " + nombre + " - " + " - " + talla + " - " + color + " - " + material + " - Precio: " + getPrecioString() + " - Cantidad: " + getCantidadString();
}
else if (categoria == "Electronica" || categoria == "electronica")
{
return id + " - " + categoria + " - " + nombre + " - " + marca + " - " + modelo + " - Precio: " + getPrecioString() + " - Cantidad: " + getCantidadString();
}
else if (categoria == "Ferreteria" || categoria == "ferreteria")
{
return id + " - " + categoria + " - " + nombre + " - " + tipo + " - " + marca + " - " + modelo + " - Precio: " + getPrecioString() + " - Cantidad: " + getCantidadString();
}
else if (categoria == "Jugueteria" || categoria == "jugueteria")
{
return id + " - " + categoria + " - " + nombre + " - " + marca + " - " + esStringEducativo() + " - Precio: " + getPrecioString() + " - Cantidad: " + getCantidadString();
}
else if (categoria == "Libreria" || categoria == "libreria")
{
return id + " - " + categoria + " - " + nombre + " - " + autor + " - " + editorial + " - Precio: " + getPrecioString() + " - Cantidad: " + getCantidadString();
}
else
{
return "Categoria no valida o vacia";
}
}
};