In a tech-driven world, the importance of skilled employees cannot be overstated. Enter "Classy Coders Inc", a software development company on a mission to revolutionize the way businesses operate. As a budding developer, you've just landed a job at this esteemed establishment and are tasked with creating a series of classes that represents employees at the company and will underlie the systems they are building.
They have provided you with the following class diagram that represents their current workforce.
Create a class Employee that has the following properties and methods:
name: A string representing the name of the employee.position: A string representing the position of the employee.salary: A private number representing the salary of the employee.isHired: A private field that initializes with a value oftrue.getSalary(): A method that returns thesalaryof the employee.setSalary(amount): A method that updates thesalaryof the employee.getStatus(): A method that returns the value ofisHired.setStatus(command): A method that updatesisHiredto:trueifcommandis"hire"falseifcommandis"fire"
const preston = new Employee("Preston", "Engineer", 100000);
preston.getSalary(); // 100000
preston.setSalary(105000);
preston.getSalary(); // 105000
preston.getStatus(); // true;
preston.setStatus("fire");
preston.getStatus(); // false;Create a subclass Manager that extends Employee (don't forget to import Employee to the Manager.js file!) and has the following additional property and methods:
department: A string representing the department the manager is in charge of.employeesManaged: A private property that holds an array ofEmployeeclass instances the manager manages. Initializes as an empty array.getEmployeesManaged(): A method that returns the employees a manager has.setEmployeesManaged(employee): A method that updates theemployeesManagedwith a newEmployee
const jenna = new Manager("Jenna", "Head of Engineers", 120000, "Software Engineering", 10);
jenna.getEmployeesManaged(); // []
const preston = new Employee("Preston", "Engineer", 100000);
jenna.setEmployeesManaged(preston);
jenna.getEmployeesManaged(); // [ Employee ]Create a class of SoftwareEngineer that extends Employee and has the following additional properties and methods:
programmingLanguages: A private property that holds an array of programming languages the software engineer knows.getProgrammingLanguages(): A method to return theprogrammingLanguagesthat the engineer knows.setProgrammingLanguage(language): A method to update theprogrammingLanguageswith a new language to the array.
const programmer = new SoftwareEngineer("Becca", "Senior Software Engineer", 100000, ["JavaScript", "Java", "Python"]);
programmer.getProgrammingLanguages(); // ["JavaScript", "Java", "Python"]
programmer.setProgrammingLanguage("C#");
programmer.getProgrammingLanguages(); // ["JavaScript", "Java", "Python", "C#"]Create a class of SalesPerson that extends Employee and has the following additional properties and methods:
clients: A property that holds an array of clients the salesperson manages.totalSales: A private field that contains the value of total sales the employee has performed. Initializes with a value of 0.getSalesNumbers(): A method that returns thetotalSalesfor the salesperson.makeSale(amount): A method that updates thetotalSaleswith theamount.
const malik = new SalesPerson("Malik", "Enterprise Sale Associate", 90000, ["Vine", "MySpace", "Shutterfly"])
malik.getSalesNumbers(); // 0
malik.makeSale(10500);
malik.makeSale(20000);
malik.getSalesNumbers(); // 30500allEmployees: A private static private property that initializes as an empty array. Every time a newEmployeeis created they are added to the end of this array.getEmployees: A static method that returns the array ofallEmployees.getTotalPayroll(): A static method that returns the total salaries of all employees that are stored in theallEmployeesarray.
const jenna = new Manager("Jenna", "Head of Engineers", 120000, "Software Engineering", 10);
const programmer = new SoftwareEngineer("Becca", "Senior Software Engineer", 100000, ["JavaScript", "Java", "Python"]);
const malik = new SalesPerson("Malik", "Enterprise Sale Associate", 90000, ["Vine", "MySpace", "Shutterfly"])
Employees.getEmployees(); // [ Manager { }, SoftwareEngineer { }, SalesPerson { }]
Employees.getTotalSalary(); // 310000- Error Handling: Add error handling to the
setSalarymethod of the Employee class. If the salary is less than0, throw an error with the message"Salary cannot be negative". - Search: Create a
findClient(client)method for theSalesPersonclass. It should return the client that matches the argument provided. - Promotions: Add a
promotemethod to theEmployeeclass. This method should take in a new job title as an argument and update the employee's job title and salary accordingly. Implement this method in theManagersubclasses as well, as they may have additional promotion criteria. - Performance Metrics: Add performance metrics to the
Employeeclass. Each employee should have a set of metrics such as sales numbers for salespeople, project completion rate for software engineers, and employee retention rate for managers. Implement a method to calculate and return the performance score based on these metrics. Design a method that use this score to determine bonuses and/or promotions.

