Project 3
//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.
#include<iostream>//input and output header files
using namespace std;//mathematical computations
#define size 3//macro definition
#define maximum 50000//macro definition
class vehicle//vehicle as a class is defined
{
public://access specifier
string make_car,model_car,type_car;// variables defined as string
enum type_car{GAS,ELECTRIC,DIESEL};// to define car type as enum
int year_car;//car year at which it was produced
float odometer_Value;//odometer value in floating point is defined
virtual void set_make();//virtual function set_make declared
virtual void put_make();//virtual function put_make declared
virtual void set_model();// virtual function set_model declared
virtual void put_model();// virtual function put_model declared
virtual void set_year();// virtual function set_year declared
virtual void put_year();// virtual function put_year declared
virtual void set_odometer();// virtual function set_odometer declared
virtual void put_odometer();// virtual function put_odometer declared
};
void vehicle::set_make() // function definition outside a class with scope resolution operator
{
cout<<"enter make of the vehicle"<<endl;
cin>>make_car;//make of the car
}
void vehicle::put_make()//function definition outside a class with scope resolution operator
{
cout<<"\t the make of the car"<<make_car;// to print the make of car
}
void vehicle::set_model()//function definition outside a class with scope resolution operator
{
cout<<"\n enter the model of the vehicle"<<endl;
cin>>model_car;//model of the car
}
void vehicle::put_model()//function definition outside a class with scope resolution operator
{
cout<<"\t the model of the car"<<model_car;//printing the model of car
}
void vehicle::set_year()//function definition outside a class with scope resolution operator
{
cout<<"\n enter manufactured year of the vehicle"<<endl;
cin>>year_car;//year of manufacturing
}
void vehicle::put_year()//function definition outside a class with scope resolution operator
{
cout<<"\t the year of the car"<<year_car<<endl;//printing the year of manufacturing
}
void vehicle::set_odometer()//function definition outside a class with scope resolution operator
{
cout<<"\n float data speedometer of the vehicle"<<endl;
cin>>odometer_Value;//odometer value for checking the distance
}
void vehicle::put_odometer()//function definition outside a class with scope resolution operator
{
cout<<"\t odometer value "<<odometer_Value;
if(odometer_Value>50000)//condition check for odometer value
cout<<"\n tyre rotation calibration is to be done"<<endl;
else
cout<<"\n less than 50000 kms-tyre rotation can be done in next time"<<endl;
}
void menu_display()//function definition for displaying menu
{
cout<<"\n 0.quit the programme\n"<<endl;
cout<<"\n 1.services that we offer\n"<<endl;
cout<<"\n 2.add vehicle details\n"<<endl;
}
void display_services()//function definition for displaying services
{
cout<<"\n oil change\n"<<"\n replace oil filter \n"<<"\n replace air filter \n"<<"\n replace fuel filter\n"
<<endl;
cout<<"\n tyre rotations"<<"\n infotaiment check\n"<<"\nreplace spark plugs\n"<<"\nreplace cabin filter\n"<<endl;
cout<<"\n check the level\n"<<"\n refill clutch fluid\n"<<"\n brake fluid\n"<<"\n examine belt, wiper hoses\n"<<endl;
cout<<"check the tyre condition\n"<<"\ncheck the charging systems\n"<<"\nbattery\n"<<endl;
}
int main()//main function definition
{
int choice;//choice as a variable
beginning:menu_display();//for displaying menu
cout<<"please enter the choice"<<endl;
cin>>choice;
switch(choice)//switch function for choice
{
case 0 :cout<<"exit the program";
break;
case 1:display_services();
goto beginning;
break;
case 2: vehicle *pv=new vehicle();//pv declared as a pointer
pv->set_make();/*pointer accessing the functions*/
pv->set_model();
pv->set_year();
pv->set_odometer();
pv->put_make();
pv->put_model();
pv->put_year();
pv->put_odometer();
goto beginning;//goto tag for repition while(1) can be used as well
break;
}
}