So I'm almost finish with my college project but they want me to ask the user which car he wants and with that data i have to create the object using the parameters that i previously asked. But if the user wants the "Audi A7" or the "BMW X6" i need to create an object using the set methods. The problem is that both of the objects show in screen. PD: Sorry for my bad english.
int main() {
string extras, marca;
cout<<endl<<" Por favor eliga uno de los siguientes vehiculos:"
<<endl<<endl;
cout<<" 1) Audi A7"<<endl;
cout<<" 2) Alfa Romero Guilietta"<<endl;
cout<<" 3) Mitsubishi Montero Wagon"<<endl;
cout<<" 4) BMW X6 "<<endl;
cout<<" 5) Mercedes Benz Clase GLS"<<endl;
cout<<" 6) Volvo XC90"<<endl;
cout<<"___________________________________________________"<<endl<<endl;
cout<<" Escriba el nombre del vehiculo deseado: "; getline(cin,marca); cout<<endl;
cout<<" Le gustaria agregarle los extras? "<<endl<<endl; cout<<" "; cin>>extras;
cout<<"___________________________________________________";
//Constructor con parametros
Vehiculo Auto1 (extras,marca);
cout<<endl<<Auto1.toString()<<endl;
locale comma_locale(std::locale(), new punto());
cout.imbue(comma_locale);
cout<<setprecision(3)<<fixed<< " El precio final es: "<<Auto1.Decision()<<" CRC"<<endl;
cout<<"___________________________________________________";
//Constructor Sin Parametros
Vehiculo Auto2;
Auto2.setMarca(marca);
Auto2.setExtras(extras);
cout<<endl<<Auto2.toString()<<endl;
cout.imbue(comma_locale);
cout<<setprecision(3)<<fixed<< " El precio final es: "<<Auto2.Decision()<<" CRC"<<endl;
cout<<"___________________________________________________";
return 0;
}
Aucun commentaire:
Enregistrer un commentaire