Dev - C++ - Modificar un dato en DEQUE

 
Vista:
sin imagen de perfil

Modificar un dato en DEQUE

Publicado por Elena (1 intervención) el 07/06/2016 13:39:28
Buenos días, estoy realizando este trabajo, utilizando la libreria DEQUE, es un registro de los clientes de una estética, cada cliente se puede diferenciar con un número. Este programa debe hacer 5 cosas : agregar (cliente nuevo), mostrar (todos los clientes), buscar, eliminar y editar. El ultimo (editar) es el que me falta, agradeceria si me pueden ayudar por favor.

#include <iostream>
#include <deque>

using namespace std;

class Cabello{

private:

string cliente;
string nombre;
string edad;
string genero;
string tipo;
string largo;
string trabajo;

public:

Cabello(){
string cliente= " ";
string nombre= " ";
string edad= " ";
string genero= " ";
string tipo= " ";
string largo= " ";
string trabajo= " ";
}

void establecercliente(string c){
cliente = c;
}

void establecernombre(string n){
nombre = n;
}

void estableceredad(string e){
edad= e;
}

void establecergenero( string g){
genero =g;
}

void establecertipo( string t){
tipo= t;
}

void establecerlargo( string l){
largo= l;
}

void establecertrabajo ( string rt){
trabajo= rt;
}

string obtenercliente(){
return cliente;
}

string obtenernombre(){
return nombre;
}

string obteneredad(){
return edad;
}

string obtenergenero(){
return genero;
}

string obtenertipo(){
return tipo;
}

string obtenerlargo(){
return largo;
}

string obtenertrabajo(){
return trabajo;
}

};


class control{

private:

deque<Cabello> dq;

public:

void nuevo (string cliente, string nombre, string edad, string genero, string tipo, string largo, string trabajo){

Cabello a;

a.establecercliente(cliente);
a.establecernombre(nombre);
a.estableceredad(edad);
a.establecergenero(genero);
a.establecertipo(tipo);
a.establecerlargo(largo);
a.establecertrabajo(trabajo);

dq.push_back(a);
}

void mostrar (){

Cabello a;

for (int i=0; i<dq.size(); i++){
a= dq.at(i);

cout << "Numero:"<<"\t";
cout << "Nombre:"<<"\t";
cout << "Edad:"<<"\t";
cout << "Genero:"<<"\t";
cout << "Tipo:" <<"\t";
cout << "Largo:"<<"\t";
cout << "Trabajo:"<<endl;
cout << a.obtenercliente() <<"\t";
cout << a.obtenernombre() <<"\t";
cout << a.obteneredad() <<"\t";
cout << a.obtenergenero() <<"\t";
cout << a.obtenertipo() <<"\t";
cout << a.obtenerlargo() <<"\t";
cout << a.obtenertrabajo()<<endl;

}
}

void busca (string cliente){

Cabello a;

for (int i=0; i<dq.size(); i++){

a=(Cabello)dq.at(i);

if(cliente == a.obtenercliente()){

cout << "Numero: " << endl;
cout << a.obtenercliente() <<endl;
cout << endl;
cout << "Nombre: " << endl;
cout << a.obtenernombre() <<endl;
cout << endl;
cout << "Edad:" <<endl;
cout << a.obteneredad() << endl ;
cout << endl;
cout << "Genero: " << endl;
cout << a.obtenergenero() <<endl;
cout << endl;
cout << "Tipo: " << endl;
cout << a.obtenertipo() << endl;
cout << endl;
cout << "Largo: " <<endl;
cout << a.obtenerlargo()<< endl ;
cout << endl;
cout << "Trabajo: " << endl;
cout << a.obtenertrabajo() << endl;
cout << endl;

}else{

cout << "no existe ningun dato con esa referencia" << endl;
}
}
}

void eliminar (string cliente){

Cabello a;

for (int i=0; i<dq.size(); i++){

a=(Cabello) dq.at(i);
int fac =i;

if( cliente == a.obtenercliente()){

dq.erase(dq.begin()+fac);

}
}
}

void editar




};

main(){
system("Color F9");

control c;
int op;
string e,b,l,n,g,t,rt;

do{
cout << endl;
cout << endl;
cout << " ----BIENVENIDOS A LA ESTETICA: MILE----- " << endl;
cout << endl;
cout << " 1. Agregar "<< endl;
cout << endl;
cout << " 2. Mostrar todo"<< endl;
cout << endl;
cout << " 3. Consultar"<<endl;
cout << endl;
cout << " 4. Eliminar"<< endl;
cout << endl;
cout << " 5. Editar"<< endl;
cout << endl;
cout << " 6. SALIR"<<endl;
cout << endl;
cout << " Ingresa una opcion: ";
cin >> op;
cout << endl;

system ("CLS");

switch ( op ){

case 1:

cout <<"N. cliente: ";
cin>>b;
cout<< endl;
cout <<"Nombre de cliente: ";
cin>>n;
cout<< endl;
cout << "Edad del cliente: ";
cin>>e;
cout<< endl;
cout << "Genero : " ;
cin>>g;
cout<< endl;
cout << "Tipo del cabello: " ;
cin>> t;
cout<< endl;
cout << "Largo del cabello: ";
cin>> l;
cout<< endl;
cout << "Trabajo: ";
cin>> rt;
cout<< endl;

c.nuevo(b,n,e,g,t,l,rt);
system ("CLS");
break;

case 2:

c.mostrar();
system("PAUSE");
system ("CLS");

break;

case 3:

cout << "N. cliente: ";
cout << endl;
cin >> b;
c.busca(b);
system("PAUSE");
system ("CLS");

break;

case 4:
cout << "cliente: ";
cin>> b;
c.eliminar(b);
system ("PAUSE");
system ("CLS");
break;

case 5:

break;


case 6:

cout << "SALIR";
break;
}


}while (op!=6);
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
1
Responder