Challenge

Project 3

Project no : 3

#include<iostream>
using namespace std;
class vehicle{
public:
int year,odometerreading;
string make,model;
enum Type{

GAS,DIESEL,ELECTRIC

};
enum Type type;

void getNewMake();
void getNewModel();
void getYear();
void getNewOdometer();
void setNewmake();
void setNewmodel();
void setYear();
void setNewodometer();
};
class Gascar{
string getType();
string getFuelType();
};
class DieselCar{
string getType();
string getFuelType();
};
class ElectricCar{
public:
string checkTireRotation(int odometerreading){
if(odometerreading>=50000){
return "replace the tires";
}
else{
return "tires are good to go";
}
}
string checkChargerPower(int odometerreading){
if(odometerreading==400){
return "battery to be recharged";
}
else{
return "your vehicle is good to go";
}
}
string getType(){
return "fuel type";
}
};

class FuelVehicle{
virtual void getFuelType()=0;


void checkOil()
{
char input;
cout<<"enter whether oil needs replacement"<<endl;
cin>>input;
if(input=='Y')
{
cout<<"Oil is replaced"<<endl;
}
else
{
cout<<"Oil is not replaced"<<endl;
}
}
};
string Gascar::getType()
{
return "the type of car is Gascar";
}
string Gascar::getFuelType()
{
return "the type of car is LPG Gas";
}
string DieselCar::getType()
{
return "the type of car is DieselCar";
}
string DieselCar::getFuelType()
{
return "the type of car is Diesel";
}
class Maintanence
{
public:
string inventory={"benz,audi,tata,xuv"};
void addVehicle()
{
string x;
cout<<"enter the car needs to be added"<<endl;
cin>>x;
inventory=x+" "+inventory;
cout<<inventory<<endl;
}
void listvehicle(){
cout<<inventory<<endl;
}
void updatevehicle(){
cout<<inventory<<endl;
}
void removevehicle(){
string re;
int pos;
cout<<"enter the vehicle to be remove"<<endl;
cin>>re;
pos=inventory.find(re);
if(pos!=string::npos){
inventory.erase(pos,re.length()+1);
cout<<inventory<<endl;
}
else{
cout<<"vehicle is not found"<<endl;
}
}
void checkTireRotation(){
int odometerreading;
cout<<"enter the odometer reading"<<endl;
cin>>odometerreading;
if(odometerreading<=50){
cout<<"replace the tires"<<endl;
}
else{
cout<<"tires are good to go"<<endl;
}
}
void checkOil()
{
char input;
cout<<"enter whether oil needs replacement"<<endl;
cin>>input;
if(input=='Y')
{
cout<<"Oil is replaced"<<endl;
}
else
{
cout<<"Oil is not replaced"<<endl;
}
}
void checkChargerPower(){
int odometerreading;
cout<<"enter the odometer reading"<<endl;
cin>>odometerreading;
if(odometerreading==400){
cout<<"battery to be recharged"<<endl;
}
else{
cout<<"your vehicle is good to go"<<endl;
}
}
};
void vehicle::setNewmake(){
cout<<"Enter the make of the car"<<endl;
cin>>make;
};
void vehicle::getNewMake(){
cout<<make<<endl;
};
void vehicle::setNewmodel(){
cout<<"the model of the car"<<endl;
cin>>model;
};
void vehicle::getNewModel(){
cout<<model<<endl;
};
void vehicle::setYear(){
cout<<"the manufacture year of the car"<<endl;
cin>>year;
};
void vehicle::getYear(){
cout<<year<<endl;
};
void vehicle::setNewodometer(){
cout<<"the reading of the car"<<endl;
cin>>odometerreading;
};
void vehicle::getNewOdometer(){
cout<<odometerreading<<endl;
};
int main(){
int year,odometer;
string make,model;
vehicle v;
Gascar g;
DieselCar d;
ElectricCar e;
Maintanence m;
FuelVehicle *f;
v.setNewmake();
v.getNewMake();
v.setNewmodel();
v.getNewModel();
v.setYear();
v.getYear();
v.getNewOdometer();
v.setNewodometer();
int choice;
while(1){
cout<<"enter the choice"<<endl;
cin>>choice;
switch(choice){
case 1:
m.addVehicle();
break;
case 2:
m.listvehicle();
break;
case 3:
m.updatevehicle();
break;
case 4:
m.removevehicle();
break;
case 5:
m.checkTireRotation();
break;
case 6:
m.checkOil();
break;
case 7:
m.checkChargerPower();
break;
default:
cout<<"exit"<<endl;
}
}
return 0;
}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.