top of page

Car  Park Manager

///MAIN//
#include "VehicleObjectCollection.h"

VehicleObjectCollection::VehicleObjectCollection(int listLength) {
    numVehicle = 4;
    
}

void VehicleObjectCollection::addVehicle(VehicleObject* Vehicle){
    
    if (VehicleList.size() < numVehicle) {
        VehicleList.push_back(Vehicle);
    }
    else {
        cout << "______________________________________________________" << endl;
        cout << "======================================================" << endl;
        cout << "            No more spaces in the Car Park" << endl;
        cout << "======================================================" << endl;
        cout << "______________________________________________________" << endl;
    }
}

void VehicleObjectCollection::printVehicleList() {


    for (int i = 0; i < VehicleList.size(); i++) {
        if (VehicleList.at(i)->getVehicle() == "Car") {
            cout << "Vehicle = Car, Brand = " << VehicleList.at(i)->getBrand() << ", ID Plate = " << VehicleList.at(i)->getIDplate() <<  endl;
            
        }
        if (VehicleList.at(i)->getVehicle() == "Motorbike") {
            cout << "Vehicle = Motorbike, Brand = " << VehicleList.at(i)->getBrand() << ", ID Plate = " << VehicleList.at(i)->getIDplate() << endl;
            
        }
        if (VehicleList.at(i)->getVehicle() == "Van") {
            cout << "Vehicle = Van, Brand = " << VehicleList.at(i)->getBrand() << ", ID Plate = " << VehicleList.at(i)->getIDplate() << endl;
            
        }
    }
}

bool VehicleObjectCollection::runMenu() {
    string IDplate;
    string Brand;
    string Colour;
    double EngineSize;
    double Doors;
    double cargoVolume;
    Car* c;
    Motorbike* m;
    Van* v;

    bool exit = false;
    cout << "______________________________________________________" << endl;
    cout << "Hello and Welcome to Westminster Car Park" << endl;    
    cout << "To add a new Vehicle press 1" << endl;
    cout << "To delete Vehicle press 2" << endl;
    cout << "To print the list of the Vehicle press 3" << endl;
    cout << "To print the Statistics 4" << endl;
    cout << "To exit press 5" << endl;
    cout << "______________________________________________________" << endl;
    int choice;
    cin >> choice;
        
    

    switch(choice) {
    case 1:
        cout << "______________________________________________________" << endl;
        cout << "Press 1 if you want to add a Car" << endl;
        cout << "Press 2 if you want to add a Motorbike" << endl;
        cout << "Press 3 if you want to add a Van" << endl;
        cout << "______________________________________________________" << endl;

        int choice2;
        cin >> choice2;
        cin.get();    

        
        
        switch (choice2) {
        case 1:
            cout << "______________________________________________________" << endl;
            // it is a Car
            cout << "Insert the Colour" << endl;            
            cin >> Colour;

            cout << "Insert the Doors" << endl;            
            cin >> Doors;

            cout << "Insert the ID Plate" << endl;
            cin >> IDplate;

            cout << "Insert the Brand" << endl;
            cin >> Brand;
            cout << "______________________________________________________" << endl;
            c = new Car(Colour,Doors,Brand,IDplate);
            numVehicle -= 1;
            CarNo += 1;
            this->addVehicle(c);
            break;

        case 2:
            // it is a Motorbike
            cout << "______________________________________________________" << endl;
            cout << "Insert the ID Plate" << endl;
            cin >> IDplate;

            cout << "Insert the Brand" << endl;
            cin >> Brand;

            cout << "Insert the EngineSize" << endl;
            
            cin >> EngineSize;
            cout << "______________________________________________________" << endl;

            numVehicle -= 1;
            MotorBikeNo += 1;
            m = new Motorbike(EngineSize,Brand,IDplate);
            this->addVehicle(m);
            break;

        case 3:
            // it is a Van
            cout << "______________________________________________________" << endl;
            cout << "Insert the ID Plate" << endl;
            cin >> IDplate;
            cout << "Insert the Brand" << endl;
            cin >> Brand;
            cout << "Insert the Volume of the Cargo" << endl;

            cin >> cargoVolume;
            cout << "______________________________________________________" << endl;
            v = new Van(cargoVolume, IDplate, Brand);
            numVehicle -= 2;
            VanNo -=1;
            this->addVehicle(v);
            break;
        }
        break;

    case 2:

        /*cout << "Insert the ID Plate" << endl;
        cin >> IDplate;
        for (int i = 0; i < VehicleList.size(); i++) {
            if (VehicleList.at(i)->getIDplate() == IDplate) {
                cout << "Vehicle = Car, Brand = " << VehicleList.at(i)->getBrand() << ", ID Plate = " << VehicleList.at(i)->getIDplate() << endl;
            }
            
        }*/
    

        break;

    case 3:
        this->printVehicleList();
        break;

    case 4:        
        TotalVehi = CarNo + VanNo + MotorBikeNo;
        CarResult = (CarNo / TotalVehi) * 100;
        VanResult = (VanNo / TotalVehi) * 100;
        MotorBikeResult = (MotorBikeNo / TotalVehi) * 100;
        cout << "There are currently " << numVehicle << " spaces left in the Car Park" << endl;
        cout << "There are currently " << CarResult << " % Car/s currently parked" << endl;
        cout << "There are currently " << MotorBikeResult << " % Motorbike/s currently parked" << endl;
        cout << "There are currently " << VanResult << " % Van/s currently parked" << endl;
        
        break;
    case 5:
        exit = true;
        break;
    }
    return exit;
}


/// Class //

#ifndef Motorbike_H
#define Motorbike_H

#include "VehicleObject.h"

class Motorbike : public VehicleObject {

protected:
    double EngineSize;

public:
    Motorbike() {
        Brand = "BMW";
        IDplate = "X234 X23";        
        EngineSize = 1;
    }

    Motorbike(double EngineSize) {
        Brand = "BMW";
        IDplate = "X234 X23";
        this->EngineSize = EngineSize;
    }

    Motorbike(double EngineSize, string Brand, string IDplate) {
        this->IDplate = IDplate;
        this->Brand = Brand;
        this->EngineSize = EngineSize;
    }

    void setEngineSize(double EngineSize) {
        this->EngineSize = EngineSize;
    }

    double getEngineSize() {
        return EngineSize;
    }
    
        void setIDplate(string Colour) {
        this->IDplate = IDplate;
    }

    string getIDplate() {
        return IDplate;
    }

    void setBrand(string Brand) {
        this->Brand = Brand;
    }

    string getBrand() {
        return Brand;
    }
    string getVehicle() {
        return "Motorbike";
    }


};

#endif

bottom of page