Using Python... write the code 1 class Employee(object): Consider the following
ID: 3708408 • Letter: U
Question
Using Python... write the code
1 class Employee(object): Consider the following (base) class. A salaried employee class Employee (object) def salary): -init-(self, self-name = name self._salary salary name, def -init-(self, Initialise a new Employee instance Parameters: name, salary): def my_name (self): return self. name 10 name (str): The employee's name salary (float): The employee's annual salary def wage(self) return 12 13 14 15 16 17 18 19 20 21 self-salary/26 # fortnight pay self, name = name self._salary salary Define a new subclass of Employee called worker. A worker has a manager, who is another employee; their manager is given as an argument to the constructor def get name (self): You should define a method get_manager that returns the worker's manager (str) Return the name bossEmployee( "Mr. Burns', 1000000) workerWorkerWaylon Smithers',2500, boss) 23 24 25 26 27 28 29 30 31 return self._name Define another subclass of Employee called Executive. An executive has a yearly bonus in addition to a wage def wage (self): (float) Return the forgnightly wage Override the Employee.wage method in order to take the bonus into account. You must call Employee.wage from Executive.wage (using super). Remember that the existing wage method calculates a fortnightly pay, but the bonus is annual return self._salary/26 executiveExecutive Joseph Bloggs'25000, 10000)Explanation / Answer
class Worker(Employee):
def __init__(self, name, salary, manager):
super.__init__(self,name,salary)
self._manager = manager
def get_manager(self):
return self._manager
class Executive(Employee):
def __init__(self, name, salary, bonu):
super.__init__(self,name,salary)
self._bonus = bonus
def wage(self):
return super.wage(self) + self._bonus/24
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.