BS(IT),SEMESTER#01
UROOJ ASGHAR KHAN
02-135242-006
Task 1:Software Development
You are tasked with creating a software system to manage the organizational structure of a
company. The company consists of various departments, each with a manager and multiple
employees. Your goal is to define structures for employees and departments and implement
functions to build and manage this company hierarchy.
OUTPUT SAMPLE
Code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Employee {
public:
Employee(string name, string position) {
this->name = name;
this->position = position;
}
void display() {
cout << "Name: " << name << ", Position: " << position << endl;
}
private:
1
, BS(IT),SEMESTER#01
UROOJ ASGHAR KHAN
02-135242-006
string name;
string position;
};
class Department {
public:
Department(string departmentName, Employee* departmentManager) {
this->departmentName = departmentName;
this->departmentManager = departmentManager;
}
void addEmployee(Employee* employee) {
employees.push_back(employee);
}
void displayDepartment() {
cout << "Department: " << departmentName << endl;
cout << "Manager: " << endl;
departmentManager->display();
cout << "\nEmployees in " << departmentName << ":" << endl;
for (auto employee : employees) {
employee->display();
}
cout << endl;
}
private:
string departmentName;
Employee* departmentManager; // Pointer to the department manager
vector<Employee*> employees; // List of employees in the department
};
int main() {
Employee* emp1 = new Employee("hasnain", "Software Engineer");
Employee* emp2 = new Employee("faiza", "QA Engineer");
Employee* emp3 = new Employee("mantasha", "Product Manager");
Employee* manager = new Employee("mani", "Engineering Manager");
Department* engineeringDepartment = new Department("Engineering", manager);
engineeringDepartment->addEmployee(emp1);
engineeringDepartment->addEmployee(emp2);
engineeringDepartment->addEmployee(emp3);
engineeringDepartment->displayDepartment();
delete emp1;
delete emp2;
delete emp3;
delete manager;
delete engineeringDepartment;
2
UROOJ ASGHAR KHAN
02-135242-006
Task 1:Software Development
You are tasked with creating a software system to manage the organizational structure of a
company. The company consists of various departments, each with a manager and multiple
employees. Your goal is to define structures for employees and departments and implement
functions to build and manage this company hierarchy.
OUTPUT SAMPLE
Code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Employee {
public:
Employee(string name, string position) {
this->name = name;
this->position = position;
}
void display() {
cout << "Name: " << name << ", Position: " << position << endl;
}
private:
1
, BS(IT),SEMESTER#01
UROOJ ASGHAR KHAN
02-135242-006
string name;
string position;
};
class Department {
public:
Department(string departmentName, Employee* departmentManager) {
this->departmentName = departmentName;
this->departmentManager = departmentManager;
}
void addEmployee(Employee* employee) {
employees.push_back(employee);
}
void displayDepartment() {
cout << "Department: " << departmentName << endl;
cout << "Manager: " << endl;
departmentManager->display();
cout << "\nEmployees in " << departmentName << ":" << endl;
for (auto employee : employees) {
employee->display();
}
cout << endl;
}
private:
string departmentName;
Employee* departmentManager; // Pointer to the department manager
vector<Employee*> employees; // List of employees in the department
};
int main() {
Employee* emp1 = new Employee("hasnain", "Software Engineer");
Employee* emp2 = new Employee("faiza", "QA Engineer");
Employee* emp3 = new Employee("mantasha", "Product Manager");
Employee* manager = new Employee("mani", "Engineering Manager");
Department* engineeringDepartment = new Department("Engineering", manager);
engineeringDepartment->addEmployee(emp1);
engineeringDepartment->addEmployee(emp2);
engineeringDepartment->addEmployee(emp3);
engineeringDepartment->displayDepartment();
delete emp1;
delete emp2;
delete emp3;
delete manager;
delete engineeringDepartment;
2