Project 3
#include <iostream>
using namespace std;
#define size 2
#define MAXKM 50000
class vehicle
{
public:
string make, model, type;
enum TYPE{PETROL,DIESEL,ELECTRIC};
int year;
float odometer;
virtual void setmake(); //subfunctions ....virtual ->inside derived class only printed
virtual void putmake();
virtual void setmodel();
virtual void putmodel();
virtual void setyear();
virtual void putyear();
virtual void setodometer();
virtual void putodometer();
};
void vehicle::setmake() //virtual -> outside the class will be visual ->::
{
cout<<"Enter the make of the vehicle"<<endl;
cin>>make;
}
void vehicle::putmake()
{
cout<<"\t"<<make;
}
void vehicle::setmodel()
{
cout<<"Enter the model of the vehicle"<<endl;
cin>>model;
}
void vehicle::putmodel()
{
cout<<"\t"<<model;
}
void vehicle::setyear()
{
cout<<"\nEnter the manufactured year of the vehicle"<<endl;
cin>>year;
}
void vehicle::putyear()
{
cout<<"\t"<<year;
}
void vehicle::setodometer()
{
cout<<"\nFloat data speedometer of the vehicle"<<endl;
cin>>odometer;
}
void vehicle :: putodometer()
{
cout<<"\t"<<odometer;
if(odometer>50000)
cout<<"\nTyre Rotation is needed."<<endl;
else
cout<<"\nIt is less than 50000 KMS; Tyre rotation can be done in next visit."<<endl;
}
void menudisplay()
{
cout << " 0. Quit.\n";
cout << " 1. displayservices.\n";
cout << " 2. Add Vehicle.\n";
}
void displayservices()
{
cout<<"\nOil change or replace oil filter, replace air filter"<<endl;
cout<<"Replace fuel filter, tire rotations, infotainment system debug"<<endl;
cout<<"Replace spark plugs, replace the cabin or a/c filter, check the level"<<endl;
cout<<"Refill clutch fluid or brake fluid"<<endl;
cout<<"Examine belts, wipers, hoses"<<endl;
cout<<"Check the tire conditions, check the charging systems and battery"<<endl;
}
int main()
{
int user_choice;
here: menudisplay();
cout<<"Enter your choice in no"<<endl;
cin >> user_choice;
switch(user_choice)
{
case 0 :cout <<"Exiting the program";
break;
case 1 : displayservices();
goto here;
case 2:
vehicle *pv=new vehicle(); //pointer->memory mapped
pv->setmake();
pv-> setmodel();
pv-> setyear();
pv-> setodometer();
pv-> putmake();
pv-> putmodel();
pv-> putyear();
pv-> putodometer();
goto here;
}
}