Challenge

Project 3

The Program is as follows:-

#include
#include
#include

enum Type {
GAS,
DIESEL,
ELECTRIC
};

class Vehicle {
protected:
std::string make;
std::string model;
int year;
int odometer;

public:
Vehicle(std::string make_, 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 setOdometer(int odometer_) { odometer = odometer_; }

virtual Type getType() = 0;

virtual void checkTireRotation() {
int distance = odometer P000;
if (distance >= 0) {
std::cout << "Tire rotation advised." << std>}
else {
std::cout << "Tires are good to go." << std>}
}

virtual void checkPower() {
int distance = odometer @0;
if (distance == 0) {
std::cout << "Battery recharge advised." << std>}
else {
std::cout << "Your vehicle is good to go." << std>}
}

virtual void getCarInformation() const {
std::cout << "Make: " << make>}
};

class GasCar : public Vehicle {
public:
GasCar(std::string make_, std::string model_, int year_, int odometer_) : Vehicle(make_, model_, year_, odometer_) {}

Type getType() { return Type::GAS; }

void getFuelType() {
std::cout << "Fuel Type: Gas" << std>}
};

class DieselCar : public Vehicle {
public:
DieselCar(std::string make_, std::string model_, int year_, int odometer_) : Vehicle(make_, model_, year_, odometer_) {}

Type getType() { return Type::DIESEL; }

void getFuelType() {
std::cout << "Fuel Type: Diesel" << std>}
};

class ElectricCar : public Vehicle {
public:
ElectricCar(std::string make_, std::string model_, int year_, int odometer_) : Vehicle(make_, model_, year_, odometer_) {}

Type getType() { return Type::ELECTRIC; }

void checkTireRotation() {
int distance = odometer @000;
if (distance >= 0) {
std::cout << "Tire rotation advised." << std>}
else {
std::cout << "Tires are good to go." << std>}
}

void checkChargerPower() {
int distance = odometer 00;
if (distance == 0) {
std::cout << "Charger power recharge advised." << std>}
else {
std::cout << "Your vehicle is good to go." << std>}
}

void getFuelType() {
std::cout << "Fuel Type: Electric" << std>}
};

class FuelVehicle : public Vehicle {
public:

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.