OBJECT ORIENTED PROGRAMMING
PROJECT
NAME : AQDAS ALI KHAN
ENROLLMENT: 09-239241-025
CLASS : RIS 3(A)
SUBMITTED TO: SIR HASSAN DANISH ,SIR ZEESHAN
SAEED
VMS
Explana7on :
In this Vehicle Management System project, core object-oriented programming principles
have been effectively implemented, including multilevel inheritance, polymorphism, and the
use of friend classes. The design begins with a base class Vehicle, which is extended by
OwnerDetails, and further inherited by MaintenanceLog and PerformanceMetrics, forming a
multilevel inheritance structure. Polymorphism is utilized through a virtual function
displayInfo() defined in the base class, enabling dynamic method binding during runtime.
Additionally, the AdminModule class is declared as a friend of Vehicle, granting it controlled
access to the private member registrationNumber to allow secure modifications.
CODE :
#include <iostream>
using namespace std;
class AdminModule;
class Vehicle {
private:
string registra<onNumber;
protected:
string model;
public:
Vehicle() {
registra<onNumber = "BEH-333";
model = "TOYOTA LC-300";
}
virtual void displayFunc() {
cout << "Model: " << model << endl;
}
friend class AdminModule;
};
class OwnerDetails {
protected:
string ownerName;
string contactInfo;
public:
OwnerDetails() {
ownerName = "AQDAS ALI KHAN";
contactInfo = "+92 341 7164372";
}
void displayFunc() {
cout << "Owner: " << ownerName << ", Contact: " << contactInfo << endl;
}
};
class InsuranceDetails {
protected:
string insuranceCompany;
string policyNumber;
public:
InsuranceDetails() {
insuranceCompany = "State Life Insurance";
policyNumber = "P700654";
}
void displayFunc() {
cout << "Insurance: " << insuranceCompany << ", Policy No: " << policyNumber << endl;
}
};
class TrafficViola<onRecord {
protected:
int challanIssued;
string viola<onDetails;
public:
TrafficViola<onRecord() {
challanIssued = 1;
viola<onDetails = "NO PARKING";
}
void displayFunc() {
cout << "Challans: " << challanIssued << ", Viola<ons: " << viola<onDetails << endl;
}
};
class MaintenanceLog : public Vehicle, public OwnerDetails, public TrafficViola<onRecord,
public InsuranceDetails {
protected:
string maintenance1, maintenance2, maintenance3;
public:
MaintenanceLog() {
maintenance1 = "1. Suspension work";
maintenance2 = "2. Engine work";
maintenance3 = "3. Fuel filter changed";
}
void displayFunc() {
Vehicle::displayFunc();
OwnerDetails::displayFunc();
TrafficViola<onRecord::displayFunc();
InsuranceDetails::displayFunc();
cout << "Maintenance:\n" << maintenance1 << "\n" << maintenance2 << "\n" <<
maintenance3 << endl;
}
};
class PerformanceMetrics : public MaintenanceLog {
protected:
float fuelEfficiency;
string engineHealth;
public:
PerformanceMetrics() {
fuelEfficiency = 8.0;
engineHealth = "GOOD";
}
void displayFunc() {
MaintenanceLog::displayFunc();
cout << "Fuel Efficiency: " << fuelEfficiency << " km/l, \nEngine Health: " <<
engineHealth << endl;
}
};
class AdminModule {
private:
string adminID;
public:
AdminModule() {
adminID = "ADM474";
}
void updateRegistra<on(Vehicle &v, string newReg) {
v.registra<onNumber = newReg;
cout << "Admin " << adminID << " \nupdated registra<on number to: " << newReg <<
endl;
}
};
int main() {
Vehicle* ptr;
PerformanceMetrics car;
ptr = &car;
cout << "\n Performance Details\n";
ptr->displayFunc();
AdminModule admin;
admin.updateRegistra<on(car, "MMM991");
return 0;
} OUTPUT :
FLOWCHART EXPLANATION :