1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Object-Oriented Programming in Python

Connected

Exercise

Method inheritance

In this exercise, you'll extend the Manager class (which is inherited from the Employee class), created in the previous exercise, by creating a method called give_raise(). It will be similar to the method of the same name in the Employee class, but include an additional argument called bonus.

The Manager class you previously created has been provided for you in script.py.

Instructions

100 XP
  • Add a give_raise() method to Manager that accepts the same parameters as Employee.give_raise(), plus a bonus argument with the default value of 1.05 (bonus of 5%).
  • Within the method, calculate new_amount by multiplying amount by bonus
  • Within the method, use the Employee's method to raise salary by new_amount.