Project 3
#include<iostream>
#include<string>
using namespace std;
class Maintenance //abstract class
{
public:
string list={"Tata Creta Ertiga"};
void List__inventory(){
cout<<"list inventory"<<list<<endl;
}
void Add_Vehicle(){
string newcar, newmake, newmodel;
int newyear;
//string list;
int type=-1;
do {
cout<<"Enter 0: GASn1.DIESELn2.ELECTRIC";
cin>>type;
if(type==0)
{
cout<<"Give the following details of the entered GAS type"<<endl;
cout<<"enter the car name need to be added"<<endl;
cin>>newcar;
cout<<"enter the car newmake to be added"<<endl;
cin>>newmake;
cout<<"enter the newmodel need to be added"<<endl;
cin>>newmodel;
cout<<"enter the newyear to be added"<<endl;
cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "<<newcar<<endl<<"make of the car"<<" "<<newcar<<endl;
}else if (type==1)
{
cout<<"Give the following details of the entered Diesel type"<<endl;
cout<<"enter the car name need to be added"<<endl;
cin>>newcar;
cout<<"enter the car newmake to be added"<<endl;
cin>>newmake;
cout<<"enter the newmodel need to be added"<<endl;
cin>>newmodel;
cout<<"enter the newyear to be added"<<endl;
cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "<<newcar<<endl<<"make of the car"<<" "<<newcar<<endl;
}
else if (type==2)
{
cout<<"Give the following details of the entered Electric type"<<endl;
cout<<"enter the car name need to be added"<<endl;
cin>>newcar;
cout<<"enter the car newmake to be added"<<endl;
cin>>newmake;
cout<<"enter the newmodel need to be added"<<endl;
cin>>newmodel;
cout<<"enter the newyear to be added"<<endl;
cin>>newyear;
list= list+" "+newcar;
cout<<"addedlist"<<" "<<newcar<<endl<<"make of the car"<<" "<<newcar<<endl;
}
}while(type<0||type>2);
}
void Update_Vehicle(){
cout<<"updatelist"<<list<<endl;
}
void Remove_Vehicle(){
cout<<"remove the vehicle from the inventory list"<<list<<endl;
string word;
cin>>word;
int pos=list.find(word);
if(pos!=string::npos)
{
list.erase(pos,word.length()+1);
cout<<"The updated list"<<" "<<list<<endl;
}
else
cout<<"The vehicle is not found"<<endl;
}
void Tire_Rotation(){
int odometer;
cout<<"Enter the odometer reading"<<endl;
cin>>odometer;//40000
int remainder = odometer-50000;
if (remainder>0)
cout<<"change tire"<<endl;
else
{
cout<<"you are good to go"<<endl;
}
}
void check_power(){
int distance;
cout<<"Enter the distance"<<endl;
cin>>distance;
if(distance>=400000)
cout<<"advise battery to be recharged"<<endl;
else
{
cout<<"your vehicle is good to go"<<endl;
}
}
void Oil_Change(){
int distance;
cout<<"Enter the distance"<<endl;
cin>>distance;
if(distance>=4000)
cout<<"car requires oil change "<<list<<endl;
else
{
cout<<"your vehicle is good to go"<<endl;
}
}
};
int main()
{
int n;
//vehicle v;
Maintenance M;
cout<<"The Menu is follows";
cout<<"0.Quit"<<endl<<"1.List inventory"<<endl<<"2.Add Vehicle"<<endl<<
"3.update Vechile"<<endl<<"4.remove Vehicle"<<endl<<"5.Tire Rotation"<<endl<<
"6.Oil Change"<<endl<<"7.Recharge"<<endl;
beginning:
cout<<"Enter the choice you want";
cin>>n;
switch(n)
{
case 0:
cout<<"You have chosen option 0"<<endl;
//exit(0);
break;
case 1:
cout<<"you have chosen option 1 "<<endl;
M.List__inventory();
goto beginning;
case 2:
cout<<"you have chosen option 2 "<<endl;
M.Add_Vehicle();
goto beginning;
case 3:
cout<<"You have chosen option 3"<<endl;
M.Update_Vehicle();
goto beginning;
case 4:
cout<<"you have chosen option 4"<<endl;
M.Remove_Vehicle();
goto beginning;
case 5:
cout<<"You have chosen option 5"<<endl;
M.Tire_Rotation();
goto beginning;
case 6:
cout<<"You have chosen option 6"<<endl;
M.Oil_Change();
goto beginning;
case 7:
cout<<"You have chosen option 7"<<endl;
M.check_power();
goto beginning;
}
return 0;
}
Output:
The Menu is follows0.Quit
1.List inventory
2.Add Vehicle
3.update Vechile
4.remove Vehicle
5.Tire Rotation
6.Oil Change
7.Recharge
Enter the choice you want1
you have chosen option 1
list inventoryTata Creta Ertiga
Enter the choice you want2
you have chosen option 2
Enter 0: GAS
1.DIESEL
2.ELECTRIC0
Give the following details of the entered GAS type
enter the car name need to be added