Question

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

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 worker’s 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

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
"""linkedQueue.py implements LinkedQueue""" class Node(object): def __init__(self, e, nextNode): self.item, self.next = (e, nextNode) def __str__(self):...
"""linkedQueue.py implements LinkedQueue""" class Node(object): def __init__(self, e, nextNode): self.item, self.next = (e, nextNode) def __str__(self): return str(self.item)    class LinkedQueue(object): def __init__(self): #O(1) self._front, self._rear =(None, None) self._size = 0    def enqueue(self, e): # add e to the rear of the queue. newTail = Node(e, None) if self.isEmpty(): self._front = newTail else: self._rear.next = newTail self._rear = newTail self._size += 1 def front(self): # raise exception if it is empty, otherwise return front element if self.isEmpty(): raise Exception("call...
Create an add method for the BST (Binary Search Tree) class. add(self, new_value: object) -> None:...
Create an add method for the BST (Binary Search Tree) class. add(self, new_value: object) -> None: """This method adds new value to the tree, maintaining BST property. Duplicates must be allowed and placed in the right subtree.""" Example #1: tree = BST() print(tree) tree.add(10) tree.add(15) tree.add(5) print(tree) tree.add(15) tree.add(15) print(tree) tree.add(5) print(tree) Output: TREE in order { } TREE in order { 5, 10, 15 } TREE in order { 5, 10, 15, 15, 15 } TREE in order {...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate class. In Worker...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):...
I NEED TASK 3 ONLY TASK 1 country.py class Country:     def __init__(self, name, pop, area, continent):         self.name = name         self.pop = pop         self.area = area         self.continent = continent     def getName(self):         return self.name     def getPopulation(self):         return self.pop     def getArea(self):         return self.area     def getContinent(self):         return self.continent     def setPopulation(self, pop):         self.pop = pop     def setArea(self, area):         self.area = area     def setContinent(self, continent):         self.continent = continent     def __repr__(self):         return (f'{self.name} (pop:{self.pop}, size: {self.area}) in {self.continent} ') TASK 2 Python Program: File: catalogue.py from Country...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT