Project 3
Project-3
Ans-
#include<iostream>
using namespace std;
#define size 2 //declaring size of vehicle
#define MAXKM 50000 //maximum kilometer run by vehicle
class vehicle
{
public: //access specifier
string make,model,type; //vehicles details
enum TYPE{Gas,Electric,Diesel}; //fuel types declared as enum
int year;
float odometer;
//functions are called inside class
virtual void setmake(); //functions are made virtual as output will be derived from derived class
virtual void putmake();
virtual void setmodel();
virtual void putmodel();
virtual void setyear();
virtual void putyear();
virtual void setodometer();
virtual void putodometer();
};
//we are calling functions outside the class
void vehicle::setmake()
{
cout<<"Enter make of the vehicle"<<endl;
cin >> make;
}
void vehicle::putmake() //scope resolution operator used
{
cout<<"\t"<<make;
}
void vehicle::setmodel()
{
cout<<"\n Enter model of the vehicle"<<endl;
cin >> model;
}
void vehicle::putmodel()
{
cout<<"\t"<<model;
}
void vehicle::setyear()
{
cout<<"\n Enter manufactured year of the vehicle"<<endl;
cin >> year;
}
void vehicle::putyear()
{
cout<<"\t"<<year;
}
void vehicle::setodometer()
{
cout<<"\n Float data speedometer of the vehicle"<<endl;
cin >> odometer;
}
void vehicle::putodometer()
{
cout<<"\t"<<odometer;
if(odometer>50000)
cout<<"\n Tyre Rotation to be done"<<endl;
else
cout<<" \n less than 50000 KMS-Tyre can be done in next visits."<<endl;
}
void menudisplay()
{
cout<< " 0.Quit.\n ";
cout<< " 1.displayservices.\n ";
cout<< " 2.Add vehicle.\n ";
}
void displayservices()
{
cout<<"\n oil change or replace oil filter,replace air filter"<<endl;
cout<<"\n replace fuel filter,fire rotations,infotainment debug"<<endl;
cout<<"\n replace spark plugs,replace cabin filter,check the level"<<endl;
cout<<"\n refill clutch fluid"<<endl;
cout<<"\n Brake fluid,examine belts,wipers,hoses"<<endl;
cout<<"\n Check fire conditions,check charging systems,battery"<<endl;
}
int main()
{int user_choice;
begining:menudisplay();
cout<<"Enter your choice in no"<<endl;
cin>>user_choice;
switch(user_choice)
{
case 0:cout<<"Exit program";
break;
case 1: displayservices();
goto begining;
case 2:
vehicle *pv=new vehicle(); //if we have new vehicle that new vehicle data should be entered with regards to function for that we are calling pointer.
//calling the function with arrow mark
pv->setmake();
pv->setmodel();
pv->setyear();
pv->setodometer();
pv->putmake();
pv->putmodel();
pv->putyear();
pv->putodometer();
goto begining;
}
};
output
