Professional Documents
Culture Documents
Specifications
Specifications
Specifications
FCIT
Objectives
• Practice on the use of the inheritance, and dynamic binding.
• Learn to use and implement polymorphism and object explicit casting.
• Learn to use and implement ArrayList class.
1
1 Description
The Employee Management System is a sophisticated Java-based application
that exemplifies the implementation of advanced object-oriented programming
(OOP) principles. This includes inheritance, polymorphism, dynamic binding,
along with the strategic use of interfaces and abstract classes. Designed to mirror
the complexity of a real-world organizational framework, it adeptly manages
employee records, showcasing Java’s capability to construct robust and scalable
applications.
Key Features
• Abstract Employee Class: At its core, the system is built around an
abstract Employee class. This class encapsulates common attributes and
methods that all employees share—such as name, ID, and base salary—acting
as a foundational blueprint for the generation of more specialized employee
types.
• Inheritance and Subclasses: Stemming from the abstract Employee
class, the system branches out into specific employee subclasses including
Manager, Developer, and Designer. These subclasses inherit the Employee
class’s attributes and methods, while also introducing distinct character-
istics or behaviors unique to each employee type, illustrating the principle
of inheritance.
2
2 How to Start
1. Examine the Provided UML
• Start by analyzing the UML diagram.
2. List of Classes to Be Created:
• Based on the given UML, you’ll create the following classes
and interface:
– Employee (abstract class): With attributes such as name,
ID, salary, and methods including calculateBonus and get-
ters/setters for attributes.
– Manager: Extends Employee and implements Approver, with
methods to approve leave and mark an employee as working.
– Developer and Designer: Both extend Employee, each with
a specific implementation of the calculateBonus method.
– Approver (interface): Defines actions like approving leave and
marking an employee as working.
– Leave: Encapsulates leave details including the employee, start
date, and duration.
– EmployeeManagementSystem: Manages the overall system,
capable of adding/removing employees, and handling leave re-
quests.
3. Understand Class Relationships:
• Utilize inheritance to extend the Employee abstract class for Man-
ager, Developer, and Designer. Implement the Approver interface
in the Manager class to grant them the ability to approve leave and
mark employees as working.
4. Abstracting System Complexity with EmployeeManagementSys-
tem:
• The EmployeeManagementSystem class acts as a crucial point of ab-
straction, significantly simplifying the use and management of the
system for users. It encapsulates the complexities of underlying op-
erations, such as managing employee records, handling leave requests,
and maintaining the employee roster.
• By providing a high-level interface to add, remove, or modify em-
ployee details, and process leave requests, EmployeeManagementSys-
tem abstracts away the direct manipulation of individual employee
objects or understanding the specifics of how leave requests are ap-
proved or denied. This design pattern follows the principle of ab-
straction, one of the core concepts of object-oriented programming,
where the system exposes only what is necessary for the user, hiding
the detailed implementation logic.
3
• Furthermore, EmployeeManagementSystem demonstrates the appli-
cation of abstraction by serving as the central interaction point.
Users of the system don’t need to interact directly with the com-
plex array of objects and their interrelationships; instead, they inter-
act with this class to manage the organizational structure efficiently.
This approach streamlines the development and maintenance of the
system, allowing for easier updates and enhancements without affect-
ing the end user’s experience.
5. Key methods within the EmployeeManagementSystem
(a) addEmployee(Employee employee): This method adds a new
employee object to the system. It takes an Employee object as an
argument and adds it to the ArrayList< Employee > that stores
all employees. Upon successfully adding an employee, it returns a
confirmation message.
(b) removeEmployee(int id): Designed to remove an employee from
the system based on their unique ID. It iterates through the employee
list, and if an employee with the given ID is found, they are removed
from the list. The method returns a success message if the employee
is successfully removed, or a failure message if no employee with the
specified ID exists.
(c) printAllEmployees(): This method generates and returns a string
that contains a formatted list of all employees in the system. Each
employee’s name, ID, salary, and Bonus are included in the output.
This method is particularly useful for obtaining a quick overview of
all the employees within the system at any given time.
(d) approveLeave(int managerId, int employeeId, LocalDate start-
Date, int days): Facilitates the approval of leave requests. It re-
quires the IDs of the manager and the employee requesting leave,
alongside the leave’s start date and duration (in days). The method
checks if the specified manager is an instance of Approver and whether
the employee exists. If both conditions are satisfied, the manager ap-
proves the leave for the employee. It returns a message indicating
whether the leave was approved or if the request failed due to var-
ious reasons (e.g., the manager ID or employee ID are incorrect or
the employee being already on leave).
(e) markEmployeeAsWorking(int managerId, int employeeId):
This method is used to update an employee’s state to ”working”
after a leave period. It checks for the existence of both the manager
and the employee in the system and verifies that the manager has
the authority to change employee states. If the criteria are met, the
employee’s state is updated, and a confirmation message is returned.
(f) findEmployeeById(int id): A utility method used internally to
find and return an Employee object based on its ID. It searches
4
through the list of employees and returns the Employee object if
found; otherwise, it returns null. This method is crucial for the re-
moveEmployee, approveLeave, and markEmployeeAsWorking meth-
ods, enabling them to locate the relevant employee objects efficiently.
(g) printEmployeeLeaveRecords(int employeeId): Generates and
returns a string containing the leave records of a specific employee,
identified by their ID. It lists all the leave instances, including start
dates and durations. This method is useful for auditing and tracking
the leave history of employees within the system.
5
• Developer: A bonus rate of 0.12 (12%) of their salary.
• Manager: A bonus rate of 0.15 (15%) of their salary.
When calculating bonuses for each employee type, the system must apply these
specific rates. This standardization aids in validating the system’s functionality,
particularly its accuracy in processing financial calculations according to defined
criteria.
6
Figure 1: UML Diagram of the Employee Management System