Question

In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In...

In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Write a ShiftSupervisor class that is a subclass of the Employee class you have seen in one of the videos about inheritance. The ShiftSupervisor class should keep a data attribute for the annual salary, and a data attribute for the annual production bonus that a shift supervisor has earned. Demonstrate the class by writing a program that uses a ShiftSupervisor object.

Using Python

Homework Answers

Answer #1

In case of any query do comment. Thanks

Note: You did not mention anything about Employee class so assumed it is having name and Age as attribute. In case of any query do comment. I will help you further.

Code:

=========main.py=======

class Employee:
    #constructor
    def __init__(self,name,age):
        self.name = name
        self.age = age
    #accessors
    def getName(self):
        return self.name
    
    def getAge(self):
        return self.age
    #mutators
    def setName(self,name):
        self.name = name
        
    def setAge(self,age):
        self.age = age
        
    def __str__(self):
        return "Name: {}, Age: {}".format(self.name,self.age)

#derived class ShiftSupervisor
class ShiftSupervisor(Employee):
    #constructor
    def __init__(self,name,age,annualSalary,annualProductionBonus):
        super().__init__(name,age) #calling super class constructor
        self.annualSalary = annualSalary
        self.annualProductionBonus = annualProductionBonus
    #accessors
    def getAnnualSalary(self):
        return self.annualSalary
    
    def getAnnualProductionBonus(self):
        return self.annualProductionBonus
    #mutators
    def setAnnualSalary(self,salary):
        self.annualSalary = salary
    
    def setAnnualProductionBonus(self,bonus):
        self.annualProductionBonus = bonus
    
    def __str__(self):
        return "{}, Salary: {:.2f}, Production Bonus: {:.2f}".format(super().__str__(),self.annualSalary,self.annualProductionBonus)

#main driver program
#create an object of ShiftSupervisor and display it
emp1 = ShiftSupervisor("Alex",28,50000,2000)
print(emp1)

========Screen shot of the code for indentation======

output:

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
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...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...