JavaScript Documentation
JavaScript Documentation
UNIVERSITY System
School of Computing CS-202
IQOR Management
System
DOCUMENTATION
Submitted by:
Section:
CS-202
Course:
Design and Implementation of Programming Languages
Instructor:
Ma. Louella M. Salenga
1 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
JavaScript CODE
const readline = require("readline-sync");
class Employee {
constructor(id, name, department, status, ratePerHr, hoursWorked, dateHired) {
this.employeeID = id;
this.employeeName = name;
this.department = department;
this.employeeStatus = this.getStatusFromNumber(status);
this.ratePerHr = ratePerHr;
this.hoursWorked = hoursWorked;
this.dateHired = dateHired;
this.Salary();
}
getStatusFromNumber(num) {
const statuses = { "1": "Probational", "2": "Permanent", "3": "Contractual" };
return statuses[num] || "Unknown";
}
Salary() {
let baseMultiplier;
let overtimeRate;
class EmployeeManager {
constructor() {
this.employees = [];
}
addEmployee(emp) {
this.employees.push(emp);
}
findEmployee(id) {
return this.employees.find(emp => emp.employeeID === id);
}
deleteEmployee(id) {
let index = this.employees.findIndex(emp => emp.employeeID === id);
if (index !== -1) {
this.employees.splice(index, 1);
return true;
}
return false;
}
}
function Menu() {
console.log(" IQOR EMPLOYEE MANAGEMENT SYSTEM ");
console.log("==========================================\n");
console.log("1. Add Employee Record");
console.log("2. Edit Employee Information");
console.log("3. Delete Employee Record");
console.log("4. Search Employee");
console.log("5. Exit\n");
}
function handleUserInput() {
let isRunning = true;
2 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
while (isRunning) {
Menu();
let option = readline.question("Enter Option Number [1-5]: ").trim();
switch (option) {
case "1":
addEmployeeRecord();
break;
case "2":
editEmployeeRecord();
break;
case "3":
deleteEmployeeRecord();
break;
case "4":
searchEmployee();
break;
case "5":
console.log("\nExiting Program...");
isRunning = false;
break;
default:
console.log("\nInsert a valid input! Please choose between 1-5.");
break;
}
}
}
function addEmployeeRecord() {
console.log("\n===========Create/Add Employee Information===========\n");
let status;
while (true) {
console.log("\nChoose Employee Status:");
console.log("1. Probational");
console.log("2. Permanent");
console.log("3. Contractual");
status = readline.question("Enter choice [1-3]: ");
if (["1", "2", "3"].includes(status)) break;
console.log("Invalid input! Choose between 1-3.");
}
let newEmployee = new Employee(ID, name, department, status, rate, hoursWorked, dateHired);
manager.addEmployee(newEmployee);
console.log("\nEmployee has been added successfully!\n");
}
function editEmployeeRecord() {
let ID = parseInt(readline.question("\nEnter Employee ID: "));
switch (option) {
case "1":
emp.employeeName = readline.question("Enter New Name: ");
break;
case "2":
emp.department = readline.question("Enter New Department: ");
break;
case "3":
while (true) {
console.log("\nChoose New Employee Status:");
console.log("1. Probational");
3 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
console.log("2. Permanent");
console.log("3. Contractual");
let status = readline.question("Enter choice [1-3]: ");
if (["1", "2", "3"].includes(status)) {
emp.employeeStatus = emp.getStatusFromNumber(status);
emp.Salary();
break;
}
console.log("Invalid input! Choose between 1-3.");
}
break;
case "4":
emp.ratePerHr = parseFloat(readline.question("Enter New Rate Per Hour (PHP): "));
emp.Salary();
break;
case "5":
emp.hoursWorked = parseFloat(readline.question("Enter New Hours Worked: "));
emp.Salary();
break;
default:
console.log("Please insert a Valid Input!");
return;
}
function deleteEmployeeRecord() {
let ID = parseInt(readline.question("\nEnter Employee ID to Delete: "));
if (manager.deleteEmployee(ID)) {
console.log("\nEmployee Deleted Successfully!\n");
} else {
console.log("\nEmployee Not Found!\n");
}
}
function searchEmployee() {
let ID = parseInt(readline.question("\nEnter Employee ID: "));
handleUserInput();
4 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
Overview
The IQOR_Management_System utilizes JavaScript to construct a basic employee management
system for the management of personnel records. Adding, amending, deleting, and searching
employee records are among the primary features. Each employee's pay is also determined by the
system according to their hours worked and status (contractual, permanent, or probationary).
Features
• Add a new employee record
• Input validation
The Employee class represents an employee and includes methods for calculating salary.
Properties:
Methods:
5 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
EmployeeManager Class
Methods:
The main program is responsible for handling user input and executing the appropriate actions.
Methods:
Salary Calculation
Base Salary Multiplier
Overtime Rate
Calculation Formula
6 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
5. Search Employee
● Search Employee ID
● Display of every available data of Employee
● Includes updatable data of Employee Salary
6. Exit
The application checks to see if the menu selection is based on user input that is in
the range of one to five. If the user selected an invalid menu option an error
message will display telling the user to select a valid option. This helps prevent
unintended behaviors and ensures that the user performs the intended menu action.
Employee status entries are limited to three valid entries only (1: Probational, 2:
Permanent, 3: Contractual) and will assume an incorrect entry to display a
second prompt.
7 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202
Conclusion
The IQOR Management System is a realistic JavaScript application that demonstrates crucial
employee management features. The system meets essential organizational needs by including
capabilities like record management, salary computation, and status categorization. It effectively
incorporates input validation and an interactive, menu-driven interface to enhance user
experience. The application of object-oriented concepts, particularly the Employee and
EmployeeManager classes, provides a structured approach to managing complex data. Overall,
the project achieves a balance between technical implementation and practical utility.
8 | Page