Project 2
PROJECT ON :-" automobile maintenance ".
#include<iostream>//my header file
#include <cstring>//string header file
using namespace std;
enum type{//enumerate data type//
DIESEL,GAS,ELECTRIC//data type members
};
class vehicle//class name vehicle
{
protected://protected access specifier
string make,model;//string is my data type make and model is members
int year,odometer,type ;//int is my data type year odometer and type is members
public://public is my access specifier
vehicle(){//vehicle() is my constructor
cout<<"enter the make of the vehicle :- ";
cin>>make;//user input data
cout<<"enter the model of the vehicle :- ";
cin>>model;//user input data
cout<<"enter the manufacturer year of the vehicle :- ";
cin>>year;//user input data
cout<<"enter the corrent odometer reading :- ";
cin>>odometer;//user input data
cout<<"enter the type of the vehicle '0->DIESEL,1->GAS,2->ELECTRIC' :- ";
cin>>type;//user input data
// cout<<"->"<<type<<endl;
}
};
class gas:public vehicle//my derived class name is gas base class is vehicle
{
protected://protected access specifier
int t=0,c=0;//int data type t and c is members
public://public access specifier
void checktirerotation()//checktirerotation() is my function member
{
cout<<"---the information based on the tire rotation :- ---"<<endl;
if(odometer>=50000)//condition is true if statement body works
{
cout<<"-the car tire must be changed the life time is over- "<<endl;
}
else {//if condition is not true else body works
t=(50000-odometer);
cout<<"--the tires is good condition \n After"<<t<<"kms the tier must be changed--"<<endl;
}
}
void checkChargerPower()//checkChargerPower() is my function member
{
cout<<"---the information based on the battery usage:- ---"<<endl;
if(odometer >=20000)//condition is true if statement body works
{
cout<<"--the battery must need be changed--"<<endl;
}
else//if condition is not true else body works
{
c=(20000-odometer);
cout<<"the battery is in good condition \n After"<<c<<"kms the battery must be changed"<<endl;
}
}
void maintenance ()//maintenance() is my function member
{
cout<<"this under maintenance part of car "<<endl;
if(odometer < 50000)//condition is true if statement body works
{
cout<<"the car tire must be changed the life time is over "<<endl;
}
else if(odometer>15000)//if condition is not true else if works
{
cout<<"replace oil filter"<<endl<<"replace fuel filter"<<endl<<" brake fluid are replace"<<endl;
}
else if(odometer>30000)//else if condition is not true this else if works
{
cout<<"replace oil filter"<<endl<<"replace fuel filter"<<endl<<" brake fluid are replace"<<endl;
cout<<"replace spark plugs"<<endl<<"replace the cabin or a/c filter";
}
else if(odometer<5000)//else if condition is not true this else if works
{
cout<<"no maintenance required for your car"<<endl;
}
}
};
class diesel:public vehicle//diesel is derived classs base class is vehicle
{
protected://protected is my access specifier
int t=0,c=0;//int data type t and c is members
public://public is access specifier
void checktirerotation()//checktirerotation() is member function
{
cout<<"the information based on the tire rotation :- "<<endl;
if(odometer>=50000)//condition is true if statement body works
{
cout<<"the car tire must be changed the life time is over "<<endl;
}
else//if condition is not true else body works
{
t=(50000-odometer);
cout<<"the tires is good condition \n After"<<t<<"kms the tier must be changed"<<endl;
}
}
void checkChargerPower()//checkChargerPower() is member function
{
cout<<"the information based on the battery usage: "<<endl;
if(odometer >= 20000)//condition is true if statement body works
{
cout<<"the battery must need be changed"<<endl;
}
else//condition is true if statement body works
{
c=(20000-odometer);
cout<<"the battery is in good condition \n After"<<c<<"kms the battery must be changed"<<endl;
}
}
void maintenance ()//maintenance() is member function
{
cout<<"this under maintenance part of car "<<endl;
if(odometer < 50000)//condition is true if statement body works
{
cout<<"the car tire must be changed the life time is over "<<endl;
}
else if(odometer>15000)//else if condition is not true this else if works
{
cout<<"replace oil filter"<<endl<<"replace fuel filter"<<endl<<" brake fluid are replace"<<endl;
}
else if(odometer>30000)//else if condition is not true this else if works
{
cout<<"replace oil filter"<<endl<<"replace fuel filter"<<endl<<" brake fluid are replace"<<endl;
cout<<"replace spark plugs"<<endl<<"replace the cabin or a/c filter";
}
else if(odometer<5000)//else if condition is not true this else if works
{
cout<<"no maintenance required for your car"<<endl;
}
}
};
class electric:public vehicle//electric is member function
{
protected://protected access specifier
int t=0,c=0;//int data type variable t and c is members
public://public access specifier
void checktirerotation()//checktirerotation() member function
{
cout<<"the information based on the tire rotation :- "<<endl;
if(odometer>=50000)//condition is true if statement body works
{
cout<<"the car tire must be changed the life time is over "<<endl;
}
else //condition is true if statement body works
{
t=(50000-odometer);
cout<<"the tires is good condition \n After"<<t<<"kms the tier must be changed"<<endl;
}
}
void checkChargerPower()
{
cout<<"the information based on the battery usage: "<<endl;
if(odometer >= 20000)//condition is true if statement body works
{
cout<<"the battery must need be changed"<<endl;
}
else//condition is true if statement body works
{
c=(20000-odometer);
cout<<"the battery is in good condition \n After"<<c<<"kms the battery must be changed"<<endl;
}
}
void maintenance ()
{//condition is true if statement b
cout<<"this under maintenance part of car "<<endl;
if(odometer < 50000)//condition is true if statement body works
{
cout<<"the car tire must be changed the life time is over "<<endl;
}
else if(odometer>15000)//else if condition is not true this else if works
{
cout<<"replace oil filter"<<endl<<"replace fuel filter"<<endl<<" brake fluid are replace"<<endl;
}
else if(odometer>30000)//else if condition is not true this else if works
{
cout<<"replace oil filter"<<endl<<"replace fuel filter"<<endl<<" brake fluid are replace"<<endl;
cout<<"replace spark plugs"<<endl<<"replace the cabin or a/c filter";
}
else if(odometer<5000)//else if condition is not true this else if works
{
cout<<"no maintenance required for your car"<<endl;
}
}
};
class review //review is class name
{
public://public access specifier
int enter;//int data type enter is my member of class
review()//review() is constructor of class
{
cout<<" give me your service feedback'0 to 5 "<<endl;
cin>>enter;//user input data
switch (enter)//switch()case function
{
case 0://user input is 0 case 0 works
cout<<"you service is not GOOD "<<endl;
break;//break function
case 1://user input is 1 case 1 works
cout<<" you service is GOOD "<<endl;
break;//break function
case 2://user input is 2 case 2 works
cout<<"i'm happy with your service"<<endl;
break;//break function
case 3://user input is 3 case 3 works
cout<<"GOOD service"<<endl;
break;//break function
case 4://user input is 4 case 4 works
cout<<"very GOOD service"<<endl;
break;//break function
case 5://user input is 5 case 5 works
cout<<"very very GOOD service"<<endl;
break;//break function
default://user not 0-5 default function works
cout<<"enter valid review"<<endl;
break;//break function
}
}
};
int main()//my main function
{
string x;//string data type x member
cout<<"enter the type of the vehicle 'DIESEL,GAS,ELECTRIC' :- ";
cin>>x;//user input
if(x=="gas")//condition is true if statement body works
{
gas g;//gas is class name and g is object
g.checktirerotation();//calling the function
g.checkChargerPower();//calling the function
g.maintenance ();//calling the function
}
else if(x=="diesel")//else if condition is not true this else if works
{
diesel d;//diesel is class name d is object
d.checktirerotation();//calling the function
d.checkChargerPower();//calling the function
d.maintenance ();//calling the function
}
else if (x=="electric")//else if condition is not true this else if works
{
electric e;//electric is class name e is object
e.checktirerotation();//calling the function
e.checkChargerPower();//calling the function
e.maintenance ();//calling the function
}
review r;//review is class name and r is object
return 0;//noting returns'
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------
output of gas class : -

--------------------------------------------------------------------------------------------------------------------------------------------------------------
output of diesel class:-

--------------------------------------------------------------------------------------------------------------------------------------------------------------
output of electronic class :-

-------------------------------------------------------------------------------------------------------------------------------------------------------------