Skip to content

Instantly share code, notes, and snippets.

@pony012
Created March 2, 2015 17:49
Show Gist options
  • Save pony012/cd7c638a46cf83ff633a to your computer and use it in GitHub Desktop.
Save pony012/cd7c638a46cf83ff633a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
class Cliente
{
public:
int id;
string nombre;
Cliente(string _nombre, int _id){
nombre = _nombre;
id = _id;
};
~Cliente(){};
};
class Bitacora
{
public:
int id, idCliente, total;
string fechaHoraEntrada, fechaHoraSalida;
Bitacora(int _id, int _idCliente){
total = 0;
id = _id;
idCliente = _idCliente;
};
~Bitacora(){};
};
class Venta
{
public:
int precio, idBitacora;
string nombre;
Venta(string _nombre, int _precio, int _idBitacora){
nombre = _nombre;
precio = _precio;
idBitacora = _idBitacora;
};
~Venta(){};
};
int main(){
int contadorClientes = 0,
contadorBitacoras = 0;
//contadorVentas = 0;
vector<Cliente> clientes;
vector<Bitacora> bitacoras;
vector<Venta> ventas;
clientes.push_back(Cliente("Alan", contadorClientes++));
clientes.push_back(Cliente("Andrés", contadorClientes++));
clientes.push_back(Cliente("Ricardo", contadorClientes++));
bitacoras.push_back(Bitacora(contadorBitacoras++, 0));
bitacoras.push_back(Bitacora(contadorBitacoras++, 2));
bitacoras.push_back(Bitacora(contadorBitacoras++, 1));
ventas.push_back(Venta("Dulces", 50, 0));
bitacoras[0].total += 50;
ventas.push_back(Venta("Playera", 150, 0));
bitacoras[0].total += 150;
ventas.push_back(Venta("Dulces", 20, 1));
bitacoras[1].total += 20;
for(unsigned int i=0; i<clientes.size(); i++){
int bitacoraId;
cout<<"Cliente: "<<clientes[i].nombre<<endl;
cout<<"Bitacora ID: ";
for(unsigned int j=0; j<bitacoras.size(); j++){
if(bitacoras[j].idCliente==clientes[i].id){
bitacoraId = bitacoras[j].id;
cout<<bitacoraId<<endl;
cout<<"Total: "<<bitacoras[j].total<<endl;
break;
}
}
for(unsigned int j=0; j<ventas.size(); j++){
if(ventas[j].idBitacora==bitacoraId){
cout<<ventas[j].nombre<<" "<<ventas[j].precio<<endl;
}
}
cout<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment