Project 3
#include <iostream>
using namespace std;
#define size 2
#define MAXKM 50000
// Class definition for the vehicle
class vehicle
{
public:
string make,model,type;
enum TYPE{ GAS,ELECTRIC,DIESEL};
int year;
float odometer;
// Virtual functions for setting and displaying vehicle details
virtual void setmake();
virtual void putmake();
virtual void setmodel();
virtual void putmodel();
virtual void setyear();
virtual void putyear();
virtual void setodometer();
virtual void putodometer();
};
// Function to set the make of the vehicle
void vehicle :: setmake()
{
cout <<"Enter make of the vehicle"<<endl;
cin>>make;
}
// Function to display the make of the vehicle
void vehicle :: putmake()
{
cout<<"\t"<<make;
}
// Function to set the model of the vehicle
void vehicle :: setmodel()
{
cout <<"Enter model of the vehicle"<<endl;
cin>>model;
}
// Function to display the model of the vehicle
void vehicle :: putmodel()
{
cout<<"\t"<<model;
}
// Function to set the year of manufacture of the vehicle
void vehicle :: setyear()
{
cout <<"Enter year of manufacture the vehicle"<<endl;
cin>>year;
}
// Function to display the year of manufacture of the vehicle
void vehicle :: putyear()
{
cout<<"\t"<<year;
}
// Function to set the odometer reading of the vehicle
void vehicle :: setodometer()
{
cout <<"Enter data speedometer of the vehicle"<<endl;
cin>>odometer;
}
// Function to display the odometer reading of the vehicle
void vehicle :: putodometer()
{
cout<<"\t"<<odometer;
if(odometer>50000)
cout<<"\n Tyre Rotation to be done"<<endl;
else
cout<<"\n Less than 50000KMs - Tyre rotation can be done in the next visit"<<endl;
}
// Function to display the menu options
void menudisplay()
{
cout<<"0) Quit.\n";
cout<<"1) Display services. \n";
cout<<"2) Add Vehicle \n";
}
// Function to display the services for the vehicle
void displayservices()
{
cout<<"\n Oil change or replace oil filter replace air filter"<<endl;
cout<<"\n Replace fuel filter , tire rotation, infotainment debug"<<endl;
cout<<"\n Replace spark plugs , replace the cabin filter , check the level"<<endl;
cout<<"\n refill the clutch fluid"<<endl;
cout<<"\n Brake fluid, examine belts, wipers, hoses"<<endl;
cout<<"\n Check the tire conditions , check the charging systems, battery"<<endl;
}
// Main function
int main()
{
int user_choices;
begining:
menudisplay();
cout<<"Enter your choice in no"<<endl;
cin>>user_choices;
switch(user_choices)
{
case 0: cout<<"Exiting the program";
break;
case 1: displayservices();
goto begining;
case 2:
vehicle *pv = new vehicle();
pv-> setmake();
pv-> putmake();
pv-> setmodel();
pv-> putmodel();
pv-> setyear();
pv-> putyear();
pv-> setodometer();
pv-> putodometer();
goto begining;
}
}
output:
