Answered step by step
Verified Expert Solution
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:
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
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.
Create a function in your main program called showworker 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 getname and
getidnumber from the base class Employee
b Use isinstance to determine if your object is a ProductionWorker or a
ShiftSupervisor and
for a ProductionWorker: call getshiftnumber and
getpayrate to get that information
for ShiftSupervisor call your method which gets the supervisor
annual salary
MY CODE:
class Employee: # use default constructorinitializer
def setnameself name:
self.name name
def setidnumberself idnumber:
self.idnumber idnumber
def getnameself:
return self.name
def getidnumberself:
return self.idnumber
class ProductionWorkerEmployee:
def setshiftnumberself shiftnumber:
self.shiftnumber shiftnumber
def setpayrateself payrate:
self.payrate payrate
def getshiftnumberself:
return self.shiftnumber
def getpayrateself:
return self.payrate
MY CODE THAT IMPORTS:
from employee import
def main:
# Get data attributes
workername inputEnter the name:
workerid inputEnter the ID number:
workershift intinputEnter the shift number:
workerpay floatinputEnter 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 fProduction worker information:
fName: workergetname
fID number: workergetidnumber
fShift: workergetshiftnumber
fHourly Pay Rate: $workergetpayrate:f
main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started