Certainly! Here's a step-by-step instruction for students that includes the creation of the classes:
- Define a class named "Employee".
- Inside the class, create a constructor method that takes four parameters:
name
,position
,yearJoined
, andsalary
. - Inside the constructor method, assign the parameter values to respective properties of the class using the "this" keyword.
- Create a method called
idBadge
that returns the Employee's position and first name in the following format:
<position>: <First Name>
- Define a class named "Manager" that extends the "Employee" class.
- Inside the class, create a constructor method that takes five parameters:
name
,position
,yearJoined
,salary
, andbonusPercentage
. - Inside the constructor method, call the super() function to invoke the constructor of the parent class (Employee).
- Assign the bonusPercentage parameter value to a new property called "bonusPercentage" of the Manager class.
- Create a method called
salaryIncrease
that will receive a parameter calledincreaseAmount
that will increase the salary of the manager.
- Create instances of the Employee class using
map
and store them into a variable calledemployees
usingemployeesJSON
. - Create instances of the Manager class using
map
and store them into a variable calledmanagers
usingmanagersJSON
. - Create a method called
logManagerInfo
. It should follow this format:<name> since <workingYears> Bonus % <bonusPercentage>
- Create a method called
getWorkingYears
which will return the total numbers of years the managers has been working.
Use array methods to perform the following operations on the provided arrays of employees and managers:
- Log the names of all employees using the forEach method using
idBadge
method. - Create a variable called
superHeroes
which will have ony employees who are developers. - Loop through all the managers and increase their salaries by 1000 using the
increaseAmount
method if they have been working for more than 11 years. - Display iterate over all the managers and invoke the
logManagerInfo
method. - Create a new array containing the names of managers whose yearJoined is before 2012 and store in into a variable called
seniorExecutives
. - Return one manager with a bonusPercentage of 0.1 and save it to a variable called
lowestBonus
. - Get the first employee with a salary greater than 8000 using the find method into a variable called
promotionCandidate
.
- Find the employee with the highest salary and save it in a variable called
mostPaidEmployee
. - Calculate the total salary of all employees and store it into a variable called
totalSalaries
. - Sort the employees array based on their yearJoined in ascending order into a variable called
employeesSorted
.