Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Inheritance Consider the following (base) class. class Employee(object): def __init__(self, name, salary): self._name = name self._salary = salary def my_name(self): return self._name def wage(self):

Using Inheritance

Consider the following (base) class.

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 # fortnight pay 

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.

You should define a method get_manager that returns the workers manager.

 boss = Employee('Mr. Burns', 1000000) worker = Worker('Waylon Smithers', 2500, boss) 

Define another subclass of Employee called Executive. An executive has a yearly bonus in addition to a 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.

 executive = Executive('Joseph Bloggs', 25000, 10000)

class Employee(object): """ A salaried employee.

""" def __init__(self, name, salary): """ Initialise a new Employee instance.

Parameters: name (str): The employee's name. salary (float): The employee's annual salary.

""" self._name = name self._salary = salary

def get_name(self): """ (str) Return the name.

""" return self._name

def wage(self): """ (float) Return the forgnightly wage.

""" return self._salary/26

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions