Project 3
/*
* C+_Proj_Vehicle maintenance.cpp
*
* Created on: Apr 13, 2023
* Author: Anbudan Balaji
*/
#include<iostream>
#include<string>
using namespace std;
class Vehicle //base class
{
protected: //protected class Members
string Make1,Make2,Make3,Model1,Model2,Model3;
int year, odometer;
public: //public class members
Vehicle(string &a,string &b,string&c,string&d,string&e,string&f,int i, int j):Make1(a),Make2(b),Make3(c),Model1(d),Model2(e),Model3(f),year(i),odometer(j)
{} //member initialised by parameterized constructor
enum Type{GAS,DIESEL,ELECTRIC}type; //enumerated type
void newgetMake() //get function
{
cout<<"Retriving your Car Data..."<<endl;
cout<<"The car make is : "<<endl<<"1. "<<Make1<<endl<<"2. "<<Make2<<endl<<"3. "<<Make3<<endl;
}
void newgetModel() //get function
{
cout<<"The car Model is : "<<endl<<"1. "<<Model1<<endl<<"2. "<<Model2<<endl<<"3. "<<Model3<<endl;
}
void newgetyear() //get function
{
cout<<"The car mfg year is : "<<year<<endl;
}
void newgetodometer() //get function
{
cout<<"The odometer Reading is : "<<odometer<<endl;
}
string inventory={"Audi, Benz, BMW,"}; //inventory list
void Quit() //quit function
{
cout<<"Thanks for Visiting us"<<endl;
}
void List_inventory() //inventory list function
{
cout<<"Welcome to inventory and vehicle list is : "<<inventory<<endl;
}
void Add_Vehicle() //function for add new vehicle
{
string Make4,Model4; //new variable
int year4;
cout<<"Enter Make of the Car to be add"<<endl;
cin>>Make4;
cout<<"Enter Model of the Car"<<endl;
cin>>Model4;
cout<<"Enter the Mfg year"<<endl;
cin>>year4;
inventory=inventory+" "+Make4; //new vehicle adding
cout<<"you have successfully added new car and updated inventory list is :"<<endl;
cout<<"Make : "<<" "<<Make4<<endl<<"Model : "<<" "<<Model4<<endl<<"Mfg year : "<<" "<<year4<<endl;
}
void Update_Vehicle() //function for update new vehicle
{
cout<<"Updated new vehicle inventory list is :"<<inventory<<endl;
}
void Remove_Vehicle() //function for remove new Vehicle
{
string x;
cout<<"Enter the Car you want to delete :"<<endl;
cin>>x;
int pos=inventory.find(x); //finding to erase string in inventory
if(pos!=string::npos) //finding newly added position
{
inventory.erase(pos,x.length()+1); //erase string in inventory
cout<<"After deleting, the updated inventory list is : "<<" "<<inventory<<endl;
}
else
cout<<"The vehicle is not found"<<endl;
}
void checkTireRotation() //check tire rotation function
{
int b ;
cout<<"Enter your car present KM in odinmeter"<<endl;
cin>>b;
if(b>=50000) //check condition below or above 50000
cout<<"Immediately Change Tire"<<endl;
else
cout<<"Your car tire is Good condition"<<endl;
}
void checkOil() //check oil condition function
{
int c;
cout<<"Enter how many KM run after Engine oil changed"<<endl;
cin>>c;
if(c>=5000) //check condition below or above 5000
cout<<"Immediately engine oil to be changed"<<endl;
else
cout<<"Your engine oil in good condition"<<endl;
}
void checkChargePower() //check charging power function
{
int d;
cout<<"Enter how many KM run after charge"<<endl;
cin>>d;
if(d>=400) //check condition below or above 50000
cout<<"Immediately battery to be recharge"<<endl;
else
cout<<"Your car battery has enough charge"<<endl;
}
};
class Gascar:public Vehicle //derived class
{
public:
void getType() //get function
{
cout<<"Your car type is : Gas"<<endl;
}
void getFueltype() //get function
{
cout<<"Your car fuel type is : LPG"<<endl;
}
};
class DieselCar:public Vehicle //derived class
{
public:
void getType() //get function
{
cout<<"Your car type is : Diesel"<<endl;
}
void getFueltype() //get function
{
cout<<"your car fuel type is : Diesel"<<endl;
}
};
class ElectricCar:public Vehicle //derived class
{
public:
void getType() //get function
{
cout<<"Your car type is : Electric"<<endl;
}
void checkTireRotation() //check tire rotation function
{
int b ;
cout<<"Enter your car present KM in odinmeter"<<endl;
cin>>b;
if(b>=50000) //check condition below or above 50000
cout<<"Immediately Change Tire"<<endl;
else
cout<<"Your car tire is Good condition"<<endl;
}
void checkChargePower() //check charging power function
{
int d;
cout<<"Enter how many KM run after charge"<<endl;
cin>>d;
if(d>=400) //check condition below or above 50000
cout<<"Immediately battery to be recharge"<<endl;
else
cout<<"Your car battery has enough charge"<<endl;
}
};
class FuelVehicle:public Vehicle //derived class
{
public:
void getFueltype() //get function
{
cout<<"Your Car Fuel is : Either Gas or Diesel"<<endl;
}
void checkOil() //check oil condition function
{
int c;
cout<<"Enter how many KM run after Engine oil changed"<<endl;
cin>>c;
if(c>=5000) //check condition below or above 5000
cout<<"Immediately engine oil to be changed"<<endl;
else
cout<<"Your engine oil in good condition"<<endl;
}
};
int main() // main function
{
int n,year,odometer; //int variable
string Make1,Make2,Make3,Model1,Model2,Model3; //string variable
cout<<"*****Retriving user data for Vehicle*****"<<endl;
cout<<"Enter vehicle Make, Model, Year and Odometer"<<endl;
cin>>Make1>>Make2>>Make3>>Model1>>Model2>>Model3>>year>>odometer;
Vehicle V(Make1,Make2,Make3,Model1,Model2,Model3,year,odometer); // parameterized constructor
while(1) //while loop
{
cout<<"Main Menu :"<<endl;
cout<<"0.Quit"<<endl<<"1.List inventory"<<endl<<"2.Add vehicle"<<endl<<"3.Update vehicle"<<endl<<"4.Remove vehicle"<<endl<<"5.Tire rotation"<<endl<<"6.Oil change"<<endl<<"7.Recharge"<<endl;
cout<<"Enter your choice"<<endl;
cin>>n;
switch(n) //switch case
{
case 0: //case 0
cout<<"Your choice : 0"<<endl;
V.Quit(); //call quit function
break; //break statement
case 1: //case 1
cout<<"your choice : 1"<<endl;
V.List_inventory(); //calling functions
V.newgetMake();
V.newgetModel();
V.newgetyear();
V.newgetodometer();
break; //break statement
case 2: //case 2
cout<<"your choice : 2"<<endl;
V.Add_Vehicle(); //calling function
break; //break statement
case 3: //case 3
cout<<"your choice : 3"<<endl;
V.Update_Vehicle(); //calling function
break; //break statement
case 4: //case 4
cout<<"your choice : 4"<<endl;
V.Remove_Vehicle(); //calling function
break; //break statement
case 5: //case 5
cout<<"Your choice : 5"<<endl;
V.checkTireRotation(); //calling function
break; //break statement
case 6: //case 6
cout<<"your choice : 6"<<endl;
V.checkOil(); //calling function
break; //break statement
case 7: //case 7
cout<<"your choice : 7"<<endl;
V.checkChargePower(); //calling functions
break; //break statement
default: //default statement
cout<<"Try again !"<<endl;
break; //break statement
}
}
return 0;
}
