Python. Please include comments where needed to explain code and include a scree
ID: 3828857 • Letter: P
Question
Python. Please include comments where needed to explain code and include a screenshot of output. Thank y
Problem 1: Employee
Write an Employee class that keeps data attributes for the following pieces of information:
• Employee name
• Employee number
Next, write two class es named ProductionWorker and ShiftSupervisor that are subclass es of the Employee class. ProductionWorker Class The P roductionWorker class should keep data attributes for the following information:
• Shift number (an integer, such as 1, 2, or 3)
• Hourly pay rate
Shift attribute will hold an integer value representing the shift that the employee w orks. The day shift is shift 1 and the night shift is shift 2.
ShiftSupervisor Class
In a particular factory, a shift supervisor is a salaried empl oyee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bo nus when his or her shift meets production goals. The ShiftSupervisor class should keep a data attribute for the :
• Annual salary
• Annual production bonus that a shift supervisor has earned.
Write the appropriate accessor and mutator methods for each class.
Once you have written the classes, write a progra m that creates two objects, object of the ProductionWorker class and an object of ShiftSupervisor r class , and prompts the user to enter data for each of the object’ s data attributes. Store the data in the object and then use the object’ s accessor methods to retrieve it and display it on the screen.
Deliverables
Turn in Project 1 .py containing all of your class and function definitions.
Explanation / Answer
class Employee: def __init__(self,name,number): self.__name = name self.number = number def set_emp_name(self,name): self.__name = name def set_emp_number(self,number): self.__number = number def get_emp_name(self): return self.__name def get_emp_number(self): return self.number class ProductionWorker(Employee): def __init__(self,name,number,shift_num,pay_rate): Employee.__init__(self,name,number) self.__shift_num = shift_num self.__pay_rate = pay_rate def set_shift_num(self,shift_num): self.__shift_num = shift_num def set_pay_rate(self,pay_rate): self.__pay_rate = pay_rate def get_shift_num(self): return self.__shift_num def get_pay_rates(self): return self.__pay_rate def main(): print('enter following Details of the Employee') emp_name = input('Enter Employee Name: ') number = input('Enter Employee Number: ') sh = input('Enter Shift Number: ') pay = input('Enter Pay Rate: ') emp = ProductionWorker(emp_name, number, sh, pay) print ('Details of Employee:') print ('Name',emp.get_emp_name()) print ('Employee Number',emp.get_emp_number()) print ('Shift Number',emp.get_shift_num()) print ('Pay Rate',emp.get_pay_rates()) if __name__ == '__main__': main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.