Challenge

Project 3

#include <iostream>

#include <vector>

#include <string>

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) {

this->make = make;

this->model = model;

this->year = year;

this->odometer = odometer;

}

std::string getMake() {

return make;

}

void setMake(std::string make) {

this->make = make;

}

std::string getModel() {

return model;

}

void setModel(std::string model) {

this->model = model;

}

int getYear() {

return year;

}

void setYear(int year) {

this->year = year;

}

int getOdometer() {

return odometer;

}

void setOdometer(int odometer) {

this->odometer = odometer;

}

virtual Type getType() = 0;

virtual void checkTireRotation() = 0;

virtual void checkChargerPower() = 0;

virtual void checkOil() = 0;

virtual void checkFuelFilter() = 0;

virtual void checkAirFilter() = 0;

virtual void checkSparkPlugs() = 0;

virtual void checkCabinFilter() = 0;

virtual void checkBelts() = 0;

virtual void checkWipers() = 0;

virtual void checkHoses() = 0;

virtual void checkTireConditions() = 0;

virtual void checkChargingSystems() = 0;

virtual void checkBattery() = 0;

virtual void getCarInformation() = 0;

};

class GasCar : public Vehicle {

public:

GasCar(std::string make, std::string model, int year, int odometer) : Vehicle(make, model, year, odometer) {}

Type getType() {

return GAS;

}

void checkTireRotation() {

int tire_cycle = 50000;

int distance_run = odometer % tire_cycle;

if (distance_run == tire_cycle || distance_run >= 0) {

std::cout << "Tire rotation advised." << std::endl;

} else {

std::cout << "Tires are good to go." << std::endl;

}

}

void checkChargerPower() {}

void checkOil() {}

void checkFuelFilter() {}

void checkAirFilter() {}

void checkSparkPlugs() {}

void checkCabinFilter() {}

void checkBelts() {}

void checkWipers() {}

void checkHoses() {}

void checkTireConditions() {}

void checkChargingSystems() {}

void checkBattery() {}

void getCarInformation() {

std::cout << "Make: " << make << std::endl;

std::cout << "Model: " << model << std::endl;

std::cout << "Year: " << year << std::endl;

std::cout << "Odometer: " << odometer << std::endl;

std::cout << "Fuel Type: Gas" << std::endl;

}

};

class DieselCar : public Vehicle {

public:

DieselCar(std::string make, std::string model, int year, int odometer) : Vehicle(make, model, year, odometer) {}

Type getType() {

return DIESEL;

}

void checkTireRotation() {

int tire_cycle = 50000;

int distance_run = odometer % tire_cycle;

if (distance_run == tire_cycle || distance_run >= 0) {

std::cout << "Tire rotation advised." << std::endl;

} else {

std::cout << "Tires are good to go." << std::endl;

}

}

void checkChargerPower() {}

void checkOil() {}

void checkFuelFilter() {}

void checkAirFilter() {}

void checkSparkPlugs() {}

void checkCabinFilter() {}

void checkBelts() {}

void checkWipers() {}

void checkHoses() {}

void checkTireConditions() {}

void checkChargingSystems() {}

void checkBattery() {}

void getCarInformation() {

std::cout << "Make: " << make << std::endl;

std::cout << "Model: " << model << std::endl;

std::cout << "Year: " << year << std::endl;

std::cout << "Odometer: " << odometer << std::endl;

std::cout << "Fuel Type: Diesel" << std::endl;

}

};

class ElectricCar : public Vehicl

If the new odometer reading is less than the previous reading, inform the user that it is an invalid input and request for a valid input again.

e {

public:

ElectricCar(std::string make, std::string model, int year, int odometer) : Vehicle(make, model, year, odometer) {}

Type getType() {

return ELECTRIC;

}

void checkTireRotation() {

int tire_cycle = 50000;

int distance_run = odometer % tire_cycle;

if (distance_run == tire_cycle distance_run >= 0) {

std::cout << "Tire rotation advised." << std::endl;

} else {

std::cout << "Tires are good to go." << std::endl;

}

}

void checkChargerPower() {

int distance = 400;

int distance_run = odometer % distance;

if (distance_run == distance) {

std::cout << "Battery recharge advised." << std::endl;

} else {

std::cout << "Vehicle is good to go." << std::endl;

}

}

void checkOil() {}

void checkFuelFilter() {}

void checkAirFilter() {}

void checkSparkPlugs() {}

void checkCabinFilter() {}

void checkBelts() {}

void checkWipers() {}

void checkHoses() {}

void checkTireConditions() {}

void checkChargingSystems() {}

void checkBattery() {}

void getCarInformation() {

std::cout << "Make: " << make << std::endl;

std::cout << "Model: " << model << std::endl;

std::cout << "Year: " << year << std::endl;

std::cout << "Odometer: " << odometer << std::endl;

std::cout << "Fuel Type: Electric" << std::endl;

}

};

class FuelVehicle : public Vehicle {

public:

FuelVehicle(std::string make, std::string model, int year, int odometer) : Vehicle(make, model, year, odometer) {}

virtual Type getFuelType() = 0;

void

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.