Project 3
Overview:
Build an object-oriented library which can be used to track automobile maintenance. There can be different car types such as petrol, diesel, gas, electric etc., This library should be able to support at least three of the car types.
Maintenance tasks include activities like oil change or replace oil filter, replace air filter, replace fuel filter, tire rotations, infotainment system debug, replace spark plugs, replace the cabin or a/c filter, check the level and refill clutch fluid or brake fluid, examine belts, wipers, hoses, check the tire conditions, check the charging systems and battery.
#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";
}
void Displayservices ()
{
cout<<"\n oil change or replace oil filter, replace air filter"<<endl;
cout<<"\n replace fuel filter, tire rotations, infotainment system debug"<<endl;
cout<<"\n replace spark plugs, replace the cabin or a/c filter"<<endl;
cout<<"\n check the level and refill clutch fluid "<<endl;
cout<<"\n brake fluid examine belts, wipers, hoses "<<endl;
cout<<"\n check the 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();
goto beginning;
}
}