123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
#include <iostream> #include <string> using namespace std; class Vehicle { protected: string Manufacturer; string Type; int Seatnumber; public: Vehicle() { Manufacturer=""; Type=""; Seatnumber=1; }; Vehicle(string manufacturer,string type,int seatnumber) { Manufacturer=manufacturer; Type=type; Seatnumber=seatnumber; }; void setmanufacturer(string manufacturer) { Manufacturer=manufacturer; }; void settype(string type) { Type=type; }; void setseatnumber(int seatnumber) { Seatnumber=seatnumber; }; string getmanufacturer() { return Manufacturer; } string gettype() { return Type; }; int getseatnumber() { return Seatnumber; }; }; class Car: public Vehicle { protected: string Carplatenumber; string Model; public: Car():Vehicle() { Carplatenumber=""; Model=""; }; Car(string carplatenumber, string model) { Carplatenumber=carplatenumber; Model=model; }; void setcarplatenumber(string carplatenumber) { Carplatenumber=carplatenumber; }; void setmodel(string model) { Model=model; }; string getcarplatenumber() { return Carplatenumber; }; string getmodel() { return Model; }; void display(); }; inline void Car::display(){ cout<<Manufacturer; cout<<Type; cout<<Seatnumber; cout<<Carplatenumber; cout<<Model; }; int main () { char choice; int size=0,seats; Car car[size]; string manufacturer,type,carplatenumber,model; cout<<"Please choice a selection: "; cin>>choice; switch(choice){ case 'A': cout<<"How many cars information do you want to store in it : "; cin>>size; cout<<"\n"; for(int i=0;i<size;i++){ cout << "Enter car "<<i+1<<" Manufacturer : "; cin >> manufacturer; car[size].setmanufacturer(manufacturer); cout << "Enter car "<<i+1<<" Type : "; cin >> type; car[size].settype(type); cout << "Enter car "<<i+1<<" Seatsnumber of the car : "; cin >> seats; car[size].setseatnumber(seats); cout << "Enter car "<<i+1<<" Model : "; cin >> model; car[size].setModel(model); } break; case'B': cout << "Hi,there please update your carplatenumber after u have gone through your new car!"; cin >> carplatenumber; car[size].setCarplatenumber(carplatenumber) break; case'C': int c=0; cout<<"Hi,which car of information would like to print our!"; cin>>c; cout<<car[c].display(); break; case'D': cout<<"Here you go!"; cout<<"========================"; for(int i=0;i<=size;i++){ car[i].display(); cout<<"======================="; } break; default:cout<<"Invalid input"; }