Project 3
Project 3 :- Program
#include <iostream>
using namespace std;
#define size 2 // Max two vehicle add
#define MAXKM 50000
class vehicle{
//base class
public: //public variable
string make,model,type;
enum TYPE{GAS,ELECTRIC,DIESEL}; //enum variable
int year; //private varible
float odometer;
virtual void setmake(); // virtual funtion derive class 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() //out side the class using scope resulation operater
{
cout<<"Enter make of vehicle"<<endl;
cin>>make;
}
void vehicle::putmake()
{
cout<<"\t"<<make;
}
void vehicle::setmodel()
{
cout<<"\n Enter model of Vehicle"<<endl;
cin>>model;
}
void vehicle::putmodel()
{
cout<<"\t"<<model;
}
void vehicle::setyear()
{
cout<<"\n Enter Year of Vehicle"<<endl;
cin>>year;
}
void vehicle::putyear()
{
cout<<"\t"<<year;
}
void vehicle::setodometer()
{
cout<<"\n float data speedometer of 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 then 50000KMS Tyre Rotation can be done in next visit "<<endl;
}
void menudisplay() //for another kind of fun
{
cout<<"0.Quit \n";
cout<<"1.Displayservices \n";
cout<<"2.Add Vehicle \n";
cout<<"3.Update Vehicle \n";
cout<<"4.Remove Vehicle \n";
}
void Displayservices ()
{
cout<<"\n oil change and replace oil filter, replace air filter"<<endl;
cout<<"\n replace fuel filter, tire rotations, information system debug"<<endl;
cout<<"\n replace spark plugs, replace the cabin and a/c filter"<<endl;
cout<<"\n check the oil level and refill clutch fluid "<<endl;
cout<<"\n brake fluid examine belts, wipers, hoses "<<endl;
cout<<"\n check tire conditions, check the charging systems and battery. "<<endl;
}
int main() {
int user_choice;
beginning: 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 beginning; // goto mean unconditional jump
case 2:
vehicle *pv=new vehicle();// * - avoiding confussion regards to memorys
pv->setmake();
pv->setmodel();
pv->setyear();
pv->setodometer();
pv->putmake();
pv->putmodel();
pv->putyear();
pv->putodometer();
}
}