Project 3
#include
using namespace std;
class Vehicle
{
public:
string make,model,type;
enum TYPE{GAS,ELECTRIC,DIESEL};
int year;
float odometer;
virtual void setmake(); //declared for set function and put functions
virtual void putmake();
virtual void setmodel();
virtual void putmodel();
virtual void setyear();
virtual void putyear();
virtual void setodometer();
virtual void putodometer();
};
void Vehicle::setmake() //call the set and put functions
{
cout<<"Enter make of the vehicle : ";
cin>>make;
}
void Vehicle::putmake()
{
cout<<"\t"< } void Vehicle::setmodel() { cout<<"Enter model of the vehicle : "; cin>>model; } void Vehicle::putmodel() { cout<<"\t"< } void Vehicle::setyear() { cout<<"Enter manufactured year of the vehicle : "; cin>>year; } void Vehicle::putyear() { cout<<"\t"< } void Vehicle::setodometer() { cout<<"Float data speedometer of the vehicle : "; cin>>odometer; } void Vehicle::putodometer() { cout<<"\t"< if(odometer>50000) cout<<"Tire Rotation to be done"< else cout<<"Less than 50000 KMS - Tire rotation can be done in next visit"< } void menuDisplay() { cout<<"0 -> Quit"< cout<<"1 -> Display services"< cout<<"2 -> Add vehicle"< } void displayServices() { cout<<"\tOil change or replace oil filter, replace air filter, replace fuel filter," "\n tire rotations, infotainment system debug, replace spark plugs, replace the cabin or a/c filter," "\n check the level and refill clutch fluid or brake fluid, examine belts, wipers, hoses," "\n check the tire conditions, check the charging systems and battery."< } int main() { int User_choice; //declared the switch variable begin: menuDisplay(); cout<<"Enter your choice in no : "; cin>>User_choice; switch(User_choice) { case 0 : cout<<"Exiting the program"; break; case 1 : displayServices(); goto begin; case 2 : Vehicle *P = new Vehicle(); //class object dynamic allocation P->setmake(); P->setmodel(); P->setyear(); P->setodometer(); P->putmake(); P->putmodel(); P->putyear(); P->putodometer(); goto begin; //goto function } return 0; }