Specifications

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Faculty of Computing & Information Technology

King Abdulaziz University

FCIT

Employee Management System

Assigned Date: 17/03/2024


Delivery Date and Time: 17/04/2024 @11:59 PM
Instructions
• This program must ONLY be submitted on the Blackboard!
• This project is worth 10% of the overall module marks (100%).
• NO assignment will be accepted after 11:59 pm for any reason.
• Students can submit their assignment between 11 and 11:59 PM, but in
this case, it will be considered late submission, and they will lose 2 points
from the total mark of the assignment.
• Further information is provided in the course syllabus.

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.

• Learn to use the instanceof operator.


• Learn to use abstract classes and interface.

Files provided with the assignment


• One input file: Input.txt
• One output file: Output.txt

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.

• Polymorphism in Action: Utilizing polymorphic methods—for exam-


ple, those used in calculating bonuses or determining vacation days—the
system showcases polymorphism and dynamic binding. These methods,
defined within the Employee class, are overridden in its subclasses to fa-
cilitate role-specific calculations.

• ArrayList for Employee Roster: For efficient employee roster manage-


ment, the system employs the ArrayList class. This approach allows for
dynamic roster modifications—such as additions, removals, and iterations
over employees—highlighting the effective use of Java collections.
• Interface for Special Permissions: The system introduces an inter-
face named Approver to outline special permissions for employees capa-
ble of approving leave requests. Implemented by selecting subclasses like
Manager, this interface marks employees with decision-making authority,
emphasizing the role of interfaces in mandating specific behaviors.
• Utilization of instanceof Operator: To identify the specific type of
an employee object at runtime, the system leverages the instanceof opera-
tor. This facilitates type-specific operations, such as casting an employee
to an Approver to execute approval methods, thereby demonstrating the
practical use of type checking and explicit casting in Java.

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.

3 Testing (Verifying System Performance and


Accuracy)
To ensure the EmployeeManagementSystem operates correctly and manages em-
ployee records efficiently as intended, a structured testing process is essential.
This process, involving the use of an input file to test the system’s functionali-
ties, ensures comprehensive evaluation.

3.1 Testing Procedure


• Input File: An input file is provided containing a series of commands de-
signed to simulate the different operations the EmployeeManagementSys-
tem can perform, such as adding employees, approving leaves, changing
employee states, and more.

• Execution: The testing should be performed within the main method


of your system. By running your system with this input file, the Employ-
eeManagementSystem will process each command sequentially, mirroring
real-world usage scenarios.

• Output File: Concurrently, an output file will be generated, containing


the results of processing all commands from the input file. This file serves
as a tangible record of the system’s responses to each operation.
• Expected Outcomes: The essence of testing lies in comparing the actual
output generated by your system against the expected output detailed in
the testing documentation. A match between these outputs indicates that
the system functions correctly and as expected, affirming its reliability in
managing employee records accurately.

3.2 Important Note on Bonus Calculation


For the purpose of simplification and to ensure consistency in testing, the bonus
percentages for each employee type have been predefined as follows:
• Designer: A bonus rate of 0.10 (10%) of their salary.

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

You might also like