Object-Oriented Programming Mini-Project with Class Inheritance on App Academy Open
- Understand how a subclass inherits from a superclass
- Know how to override a parent class's method
- Know when and how to use super
-
Class Employee has attributes that return the employee's name, title, salary, and boss.
-
Class Manager extends Employee. Manager has an attribute that holds an array of all employees assigned to the manager. Managers might report to higher level managers.
-
Method bonus(multiplier) on Employee class. Non-manager employees should get a bonus like this
bonus = (employee salary) * multiplier
- Managers should get a bonus based on the total salary of all of their subordinates, as well as the manager's subordinates' subordinates, and the subordinates' subordinates' subordinates, etc.
bonus = (total salary of all sub-employees) * multiplier
If we have a company structured like this:
Name Salary Title Boss
Ned \$1,000,000 Founder nil
Darren \$78,000 TA Manager Ned
Shawna \$12,000 TA Darren
David \$10,000 TA Darren
then we should have bonuses like this:
ned.bonus(5) # => 500_000
darren.bonus(4) # => 88_000
david.bonus(3) # => 30_000