Project 3

code :
#include
#include
enum class Type {
GAS,
DIESEL,
ELECTRIC
};
class Vehicle {
protected:
std::string make;
std::string model;
int year;
int odometer;
public:
Vehicle(const std::string& make, const std::string& model, int year, int odometer)
: make(make), model(model), year(year), odometer(odometer) {}
std::string getMake() const {
return make;
}
std::string getModel() const {
return model;
}
int getYear() const {
return year;
}
int getOdometer() const {
return odometer;
}
void checkTireRotation() {
// Code for checking tire rotation
}
void getCarInformation() {
// Code for getting car information
}
virtual Type getType() = 0;
};
class GasCar : public Vehicle {
public:
GasCar(const std::string& make, const std::string& model, int year, int odometer)
: Vehicle(make, model, year, odometer) {}
Type getType() override {
return Type::GAS;
}
// Additional functions specific to GasCar
};
class DieselCar : public Vehicle {
public:
DieselCar(const std::string& make, const std::string& model, int year, int odometer)
: Vehicle(make, model, year, odometer) {}
Type getType() override {
return Type::DIESEL;
}
// Additional functions specific to DieselCar
};
class ElectricCar : public Vehicle {
public:
ElectricCar(const std::string& make, const std::string& model, int year, int odometer)
: Vehicle(make, model, year, odometer) {}
Type getType() override {
return Type::ELECTRIC;
}
// Additional functions specific to ElectricCar
};
int main() {
// Example usage of the classes
GasCar gasCar("Toyota", "Corolla", 2021, 5000);
DieselCar dieselCar("Ford", "F-150", 2022, 8000);
ElectricCar electricCar("Tesla", "Model 3", 2023, 3000);
// Accessing attributes and calling functions
}