Lebanese University
Faculty of Sciences – section 5
I2211 – Object Oriented Programming
Exercise 2
Consider the following problem definition about companies and their offices, departments, and
employees:
Each company has a name and one or more offices. Departments are located in one or more
offices. An office has an address and one or more departments. One office in a company acts as
headquarter (central office). Each department has a name and a manager who is recruited from
the set of employees. An employee has a name and a title. The employees are associated with
the department they work in.
Note: If the company ceases to exist then the offices and departments should also be erased.
1. Define the UML class diagram for the presented problem. Show the details of each class
(list of attributes, constructor(s), and methods). All data fields should be private.
2. Implement the different classes of your model.
3. Implement a testing class with a main method in which you have to create one company
named “New Tech” with 2 offices located at Nabatieh and Tyr. The headquarter of this
company is the office located at Nabatieh. Add to the Nabatieh office an IT department and
to the Tyr office a human resources department and maintenance department. Once your
objects are created, propose to the user to add new employees to the company offices.
Propose a general menu to the user where she/he could be able to choose the office and
department of each employee. The user should also be able to enter as many employees
as needed during each run of your program.
Page 1/1