You are on page 1of 7

Lab12: FlyingCar, Employee Management

System

Date: 28th November 2023


Lab Engineer: Mehwish Kiran

Name: Muhammad Arham Siddiqui


CMS: 428887
Section: BEE-14B
Task 1:
Create a class hierarchy for a Flying Car, inheriting properties from both Car and Aircraft
classes.

CODE:
#include <iostream>
#include <string>
using namespace std;

class Car{
public:
string make;
string model;
int year;
string color;

Car():make(""),model(""),year(0),color(""){}
Car(string _make, string _model,int _year,string _color):
make(_make),model(_model),year(_year),color(_color){}

void drive (){


cout<<"Driving the Car"<<endl;
}

void displayInfo(){
cout<<"The make of the car is: "<<make<<"\nThe model of the Car is:
"<<model<<"\nThe year of the Car is: "<<year<<"\nThe color of the Car is:
"<<color<<"\n|*****************************************|\n"<<endl;
}
};

class Aircraft{
public:
string manufacturer;
string model;
string fuelType;

Aircraft():manufacturer(""),model(""),fuelType(""){}
Aircraft(string _manufacturer, string _model, string
_fuelType):manufacturer(_manufacturer),model(_model),fuelType(_fuelType){}

void fly(){
cout<<"Flying the Aircraft"<<endl;
}

void displayInfo(){
cout<<"The manufacturer of the Aircarft is: "<<manufacturer<<"\nThe model
of the Aircraft is: "<<model<<"\nThe FuelType of the Car is:
"<<fuelType<<"\n|*****************************************|\n"<<endl;
}
};

class FlyingCar:public Car,public Aircraft{


public:
FlyingCar(string carMake, string carModel, int carYear, string
carColor,string aircraftManufacturer, string aircraftModel, string
aircraftFuelType)
: Car(carMake, carModel, carYear, carColor),
Aircraft(aircraftManufacturer, aircraftModel, aircraftFuelType) {}

void activateFlightMode() {
cout << "Flight mode activated for the flying car." << endl;
}

};

int main(){
FlyingCar myFlyingCar("Toyota", "SkyGlider", 2023, "Silver", "Boeing",
"SkyMaster", "Diesel");

myFlyingCar.drive();
myFlyingCar.Car::displayInfo();

myFlyingCar.fly();
myFlyingCar.Aircraft::displayInfo();
myFlyingCar.activateFlightMode();

return 0;
}
OUTPUT:
Task 2:
Consider an employee management system where:
Employee:
Represents the base class containing common properties and methods for all employees.
Methods might include work(), calculateSalary(), etc.
Manager:
Inherits from Employee.
Contains managerial-specific functionalities and overrides some methods (e.g., work() might
include
additional supervisory tasks).
Developer:
Also inherits from Employee.
Contains developer-specific functionalities and overrides some methods (e.g., work() might
involve coding
tasks).
TeamLead:
Inherits from both Manager and Developer.
Represents a role that requires managerial responsibilities from Manager and technical
expertise from
Developer.

CODE:
#include <iostream>
#include <string>
using namespace std;

class Employee{
public:
string name;
int employeeId;
double baseSalary;

Employee(string _name, int _employeeId, double _baseSalary) : name(_name),


employeeId(_employeeId), baseSalary(_baseSalary) {}

virtual void work() {


cout << "Employee is working." << endl;
}

virtual double calculateSalary() {


return baseSalary;
}
};

class Manager: public Employee{


public:
Manager(string name, int employeeId, double baseSalary) : Employee(name,
employeeId, baseSalary) {}

void manageTeam() {
cout << "Manager is managing the team." << endl;
}

void work() override {


cout << "Manager is working and supervising." << endl;
}

};

class Developer : public Employee {


public:
Developer(string name, int employeeId, double baseSalary): Employee(name,
employeeId, baseSalary) {}

void writeCode() {
cout << "Developer is writing code." << endl;
}

void work() override {


cout << "Developer is working on coding tasks." << endl;
}
};

class TeamLead : public Manager, public Developer {


public:
TeamLead(string name, int employeeId, double baseSalary): Manager(name,
employeeId, baseSalary), Developer(name, employeeId, baseSalary) {}

void work() override {


cout << "TeamLead is working, managing, and coding." << endl;
}

double calculateSalary(){
return Manager::baseSalary;
}
};

int main() {
Manager manager("Ali", 101, 80000.0);
Developer developer("Wozniak", 201, 70000.0);
TeamLead teamLead("Arham TeamLead", 301, 90000.0);

manager.work();
cout << "Manager Salary: $" << manager.calculateSalary() <<endl;
cout << endl;

developer.work();
cout << "Developer Salary: $" << developer.calculateSalary() <<endl;
cout <<endl;

teamLead.work();
cout << "TeamLead Salary: $" << teamLead.calculateSalary() <<endl;

return 0;
}
OUTPUT:

You might also like