Write My Paper Button

WhatsApp Widget

ICT162:Object Oriented Programming Question 1 For companies resuming operations after the circuit breaker period, all Safe Management Measures should be in place before operations can be resumed at the workplace. One of these measures is to support as many employees in working from home as possible. Refer to the class diagram in Figure 1. The Employee classes used for Leave Application System are enhanced to record if an employee is “work-from-home” (WFH).

ICT162:Object Oriented Programming

Question 1

For companies resuming operations after the circuit breaker period, all Safe Management  Measures should be in place before operations can be resumed at the workplace. One of these  measures is to support as many employees in working from home as possible.

Refer to the class diagram in Figure 1. The Employee classes used for Leave Application  System are enhanced to record if an employee is “work-from-home” (WFH).

a) Implement the Employee class.

The Employee class is an abstract superclass that models one employee, which has:

Four instance variables: _employeeId (int), _name (string), _workFromHome
(boolean) and _leaveBalance (int). For this TMA, we do not consider ½ day leave. All leaves applied are full day.

Constructor that initialises all variables except _leaveBalance is set to 0.

Getter methods for the 4 instance variables. Use the property decorator.

Setter method for _workFromHome. Use the setter decorator.

There is one abstract method – getLeaveEntitlement which returns the number of leave entitlement for this employee.

Method adjustLeave takes in a parameter adjustment (int) and add to the
_leaveBalance.

The __str__ method returns a string representation of an Employee object. Here is  an example in the suggested format:

ID: 101 Name: Jeff Leave Balance: 20 WFH: No

b) Implement the Part Time Employee class.

The PartTimeEmployee class is a subclass of Employee, and it has:

One additional instance variable: _hoursPerWeek representing the hours this part  time employee worked in a week.

Besides initialising the instance variable _hoursPerWeek, the constructor also  determines the starting leave balance for part time employees.

The method getLeaveEntitlement computes and returns the starting leave balance  for part time employees using class variable _LEAVE_ENTITLEMENT, which is  a dictionary that represents the following table:

c) Implement the FullTimeEmployee and Manager classes.

The FullTimeEmployee class is a subclass of Employee, and it has:

One additional instance variable: _grade representing the grouping of the employees with similar positions or values in order to assign leave entitlement.

Beside initialising the instance variable _grade, the constructor also determines the  starting leave balance for full time employees.

The method getLeaveEntitlement computes and returns the starting leave balance  for full time employees using class variable _LEAVE_ENTITLEMENT, which is  a dictionary representing the following table:

The __str__ method returns a string representation of a FullTimeEmployee object.  This is an example in the suggested format:
ID: 101 Name: Jeff Leave Balance: 20 WFH: No Grade: 3

The Manager class is a subclass of FullTimeEmployee.

There is no additional instance variable.

The method getLeaveEntitlement references the class variable
_LEAVE_ENTITLEMENT to return the leave balance for managers.

d) Write a main() function to do the following:

i) Create the appropriate Employee objects with these details.

ii) Put the Employee objects created in (i) into a collection and invoke the __str__ method  of the Employee objects. Your results should look like the following:

ID: 101 Name: Jeff Leave Balance: 20 WFH: No Grade: 3
ID: 102 Name: Jim Leave Balance: 22 WFH: Yes Grade: 4
ID: 103 Name: Joe Leave Balance: 10 WFH: No Hours/Week: 20
ID: 104 Name: Jack Leave Balance: 18 WFH: Yes Grade: 2
ID: 105 Name: Jane Leave Balance: 16 WFH: No Grade: 1
ID: 106 Name: Tom Leave Balance: 25 WFH: No Grade: 4
ID: 201 Name: Neil Leave Balance: 25 WFH: No Grade: 4
ID: 205 Name: Charles Leave Balance: 22 WFH: No Grade: 4
ID: 204 Name: Darren Leave Balance: 12 WFH: Yes Hours/Week: 32
ID: 203 Name: Elliot Leave Balance: 20 WFH: No Grade: 3
ID: 202 Name: Fred Leave Balance: 5 WFH: Yes Hours/Week: 10

(iii) The company needs to rotate the employees’ workplace arrangement every 2 weeks.  Write codes to toggle the Work-From-Home setting for each employee. That is from True to False, or False to True. Print out the results similar to (ii) to show that WFH  is toggled successfully.

CLAIM YOUR 30% OFF TODAY

X
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?