Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Object-Oriented Programming

Lab session #4

Question 1: Has-A-Relation, non-primitive data type and UML (100 points)

 Write a class Employee which consists of:


- Private attributes employeeId, employeeName, salaryPerHour, noOfLeavingDay,
noOfTravelDay with appropriate getter and setter methods. All attributes are non-
primitive data types (Integer and String).
- Two Constructors (Overloading), set all attributes to null if no parameter is passed
to the Constructor

- Method calculateWeeklySalary with formula: salaryPerHour*8*(5 -


noOfLeavingDay + noOfTravelDay/2)
- Method toString return String (For example: “[Name: David - Salary Per Hour:40$ -
Weekly Salary:300$]”)
 Write a class Project which consists of:
- Private attributes projectID, startDate, endDate, listOfEmployee with appropriate
getter and setter methods (author attribute is Author object). The getter and setter
for listOfEmployee requires to get index parameters.
- Two Constructors (Overloading), set all attributes to null if no parameter is passed
to the Constructor
- Methods addEmployee, removeEmployee to add and remove Employee from the
ArrayList. Method displayListOfEmployee to print out all the employees in the
project.

For example: project.displayListOfEmployee()

Expected output:

The project has 2 employee(s):


1. Employee Name: VanA, ID: ITIU2003
SalaryPerHour: 20$, WeekSalary: 400$
2. Employee Name: VanB, ID: ITIU2004
SalaryPerHour: 25$, WeekSalary: 500$

- Methods estimateBudget to compute all of salaryPerHour from the employees


multiply with the duration of the Project (duration between startDate and endDate)
with the formula salaryPerHour*8*duration. Where duration is in days unit.
 Hint: startDate = 22/04/2020, endDate = 27/04/2020 -> duration = 5 days
- Method toString return String

 For example: “[Project ID: CAPSTONE102 - Project Duration: 23/5/2023 to


26/5/2023] [Number of Employees: 5 - Estimated Budget: 1000$]”
 Create a class YourNameQ1 (for example VanAQ1) that contains method main,
create list of Employee objects, insert all employee to Project object, display all
needed information to concole.

You might also like