Estructuras y Funciones en C++ para Gestión de Restaurantes
Estructuras de Datos en C++
Definición de las estructuras principales para el manejo de ingredientes, cantidades y platos en el sistema:
struct tIngrediente{
string id_I, nombre;
string categoria;
float precio;
};
struct tIngreCant{
string id_I;
float cant;
};
struct tPlato{
string id_P, nombre;
string categoria;
float precio, costo;
vector <tIngreCant> Ingrs;
};
Prototipos de Funciones
Declaración de las funciones encargadas de la gestión de menús, lectura de datos y actualización:
char ListaMenu();
char ListaMenuTipo();
void LeerIngredientes(vector <tIngrediente> & II);
void LeerPlatos(vector <tPlato> & PP); void BuscaPlatosSin(const vector <tPlato> & PP, string id_I, vector <string> Res);
void ListaIngredientes(const vector <tIngrediente> & II);
void ListaPlatos(const vector <tPlato> & PP); void RepoPlatos(const vector <tPlato> & PP);
void NuevoPlato(vector <tPlato> & PP);
void SeleccionaIngredienteTipo(const vector <tIngrediente> & II, string id_I);
void ActualizaPlatos(vector <tPlato> & PP);
void ActualizaIngredientes(vector <tIngrediente> & II);
Implementación de Funciones
Desarrollo del código fuente para las operaciones de lectura de archivos y despliegue de menús:
char ListaMenuTipo(){
char op;
cout << endl << endl;
cin >> op;
return (op);
}
char ListaMenu(){
char op;
cout << endl << endl;
cin >> op;
return (op);
}
void LeerIngredientes(vector <tIngrediente> & II){
ifstream F ("Ingredientes.txt");
tIngrediente tI;
while(F >> tI.id_I >> tI.nombre >> tI.categoria >> tI.precio) II.push_back(tI);
cout << II.size() << " ingredientes leidos." << endl;
}
void LeerPlatos(vector <tPlato> & PP){
ifstream G ("Platos.txt");
tPlato tc;
tIngreCant ing;
ing.id_I = "Hola";
while(G >> tc.id_P >> tc.nombre >> tc.categoria >> tc.precio >> tc.costo ) {
while(G >> ing.id_I >> ing.cant and ing.id_I != "FIN") tc.Ingrs.push_back(ing);
PP.push_back(tc);
tc.Ingrs.clear();
}
cout << PP.size() << " Platos leidos." << endl;
}