This is my homework, I saw it earlier on the site, but it seems that it was not resolved, and I got a different error message than the one who asked this question before.
The first part of the problem is to define a subclass of Worker that inherits from Employee and includes an attribute that refers to another employee who is the work manager. You must define the get_manager method that returns the worker manager.
Example:
worker = Worker("Fred", 52000, myboss)
The second part of the problem is to define an Executive subclass that inherits from Employee and includes an attribute that refers to the annual bonus.
You must redefine the salary method to calculate remuneration based on its salary and bonus. You must use the Employee pay method in determining the pay method for the Executive class.
Example:
executive = Executive("Kerry", 520000, 1040000)
My code is written below and an error message appears: "global name" salary "is not defined" in the line "Employee". init ("I", "name, salary") for the Executive class (works for the Worker class). Why am I getting this error and how to fix it?
Thank you for your help!
class Employee(object): def __init__(self, name, salary): self._name = name self._salary = salary def my_name(self): return self._name def wage(self): return self._salary/26
source share