Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python: Need assistance, with my code ( need fixed ) so far from both files, how do I do the following: 1 . Instantiate an

Python: Need assistance, with my code (need fixed) so far from both files, how do I do the following:
1. Instantiate an object of class ProductionWorker named worker
use the mutator methods of the class ProductionWorker to initialize the
name, id, shift number & hourly pay rate from the input variables above
2. add 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.
3. Create a function in your main program called show_worker that has a
single parameter of an worker object (accepts any employee class object as
argument) and will display all information about your workers (hint copying fstring statements from ProductionWorker and ShiftSupervisor objects in your
main program will make this task easier) and specifically:
a) For both ProductionWorker and ShiftSupervisor calls get_name and
get_id_number from the base class Employee
b) Use isinstance to determine if your object is a ProductionWorker or a
ShiftSupervisor and
1) for a ProductionWorker: call get_shift_number() and
get_pay_rate() to get that information
2) for ShiftSupervisor call your method which gets the supervisor
annual salary
MY CODE:
class Employee: # use default constructor/initializer
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
MY CODE THAT IMPORTS:
from employee import *
def main():
# Get data attributes
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 and then use
# mutators of employee.py to initialize attributes
# print the worker you just instantiated information
print (f'Production worker information:
'
f'Name: {worker.get_name()}
'
f'ID number: {worker.get_id_number()}
'
f'Shift: {worker.get_shift_number()}
'
f'Hourly Pay Rate: ${worker.get_pay_rate():,.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

More Books

Students also viewed these Databases questions

Question

How does selection differ from recruitment ?

Answered: 1 week ago