Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with python code following: Making the Employee class an abstract class Adding a ShiftSupervisor subclass of employee with an accessor and mutator method

Need help with python code following:
Making the Employee class an abstract class
Adding a ShiftSupervisor subclass of employee with an accessor and mutator
method for each of the two added subclass attributes, annual salary and
annual production bonus that a shift supervisor has earned. Naming the
accessor method get_bonus for the annual production bonus.
My code (part 1)
class Employee:
def set_name(self, name):
self.__name = name
def set_id_number(self, id_number):
self.__id_number = id_number
def get_name(self):
return self.__name
def get_id_number(self):
return self.__id_number
class ProductionWorker(Employee):
def set_shift_number(self, shift_number):
self.__shift_number = shift_number
def set_pay_rate(self, pay_rate):
self.__pay_rate = pay_rate
def get_shift_number(self):
return self.__shift_number
def get_pay_rate(self):
return self.__pay_rate
class ShiftSupervisor(Employee):
def set_annual_salary(self, annual_salary):
self.__annual_salary = annual_salary
def set_annual_bonus(self, annual_bonus):
self.__annual_bonus = annual_bonus
def get_annual_salary(self):
return self.__annual_salary
def get_annual_bonus(self):
return self.__annual_bonus
My code part two:
from employee import *
def main():
worker_name = input('Enter the name: ')
worker_id = input('Enter the ID number: ')
worker_shift = int(input('Enter the shift number: '))
worker_pay = float(input('Enter the hourly pay rate: '))
# Create an instance of ProductionWorker
worker = ProductionWorker()
worker.set_name(worker_name)
worker.set_id_number(worker_id)
worker.set_shift_number(worker_shift)
worker.set_pay_rate(worker_pay)
# Display worker information
print('Production worker information:')
print(f'Name: {worker.get_name()}')
print(f'ID number: {worker.get_id_number()}')
print(f'Shift: {worker.get_shift_number()}')
print(f'Hourly Pay Rate: ${worker.get_pay_rate():,.2f}')
# You can add similar code for ShiftSupervisor here after instantiating it
def show_worker(worker):
print(f'Name: {worker.get_name()}')
print(f'ID Number: {worker.get_id_number()}')
if isinstance(worker, ProductionWorker):
print(f'Shift Number: {worker.get_shift_number()}')
print(f'Hourly Pay Rate: ${worker.get_pay_rate():,.2f}')
elif isinstance(worker, ShiftSupervisor):
print(f'Annual Salary: ${worker.get_annual_salary():,.2f}')
print(f'Annual Production Bonus: ${worker.get_annual_bonus():,.2f}')
main()

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions