Question

Create the Python code for a program adhering to the following specifications. Write an Employee class...

Create the Python code for a program adhering to the following specifications.

Write an Employee class that keeps data attributes for the following pieces of information:

- Employee Name (a string)

- Employee Number (a string)

Make sure to create all the accessor, mutator, and __str__ methods for the object.

Next, write a class named ProductionWorker that is a subclass of the Employee class. The

ProductionWorker class should keep data attributes for the following information:

- Shift number (an integer, such as 1 or 2)

- Hourly pay rate (a float)

Make sure to create all the accessor, mutator, and __str__ methods for the object.

Once you have completed the class definitions, write the main line code that prompts the user to enter

data for each of the object’s data attributes. Create an instance of the ProductionWorker class and store

the data in the object and then use each of the object’s accessor methods from outside the

class/subclass definition to retrieve all the data and display it to the screen.

Additional notes:

-You MUST use the provided program template.

-Your messages and prompts should look like those in the sample. Duplicating all blank lines and

spacing.

  • You must create all accessor, mutator and __str__ methods
  • The accessor methods will return ONLY the value of the data attribute

-You decide to use public or “private” data attributes

- You do not need to document your variable for this program.

SAMPLE RUN:

Enter the name: John Stewart

Enter the ID number: 002

Enter the shift number: 1

Enter the hourly pay rate: 23.50

Production worker information

-----------------------------

Name: John Stewart

ID number: 002

Shift: 1

Hourly Pay Rate: $23.50

Run complete. Press the Enter key to exit.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code in Python:

class Employee:
#parametrized constructor
def __init__(self,name:str,number:str):
self.__name=name
self.__number=number
#setter methods
def setName(self,name:str):
self.__name=name
def setNumber(self,number:str):
self.__number=number
#getter methods
def getName(self):
return self.__name
def getNumber(self):
return self.__number
#method to return a str representation of the object
def __str__(self):
return "Name: "+self.__name+"\nID Number: "+self.__number
  
class ProductionWorker(Employee):
#parametrized constructor
def __init__(self,name:str,number:str,shift:int,pay:float):
Employee.__init__(self,name,number)
self.__shift=shift
self.__pay=pay
#setter methods
def setShift(self,shift):
self.__shift=shift
def setPay(self,pay):
self.__pay=pay
#getter methods
def getShift(self):
return self.__shift
def getPay(self):
return self.__pay
#method to return a str representation of the object
def __str__(self):
return Employee.__str__(self)+"\nShift: "+str(self.__shift)+"\nHourly Pay Rate: $"+str(self.__pay)

#testing the classes
name=input("Enter the name: ")
number=input("Enter the ID number: ")
shift=int(input("Enter the shift number: "))
pay=float(input("Enter the hourly pay rate: "))
e=ProductionWorker(name,number,shift,pay)
print()
print("Production Worker Information")
print("-----------------------------")
print(e)

Output:

Add a comment
Know the answer?
Add Answer to:
Create the Python code for a program adhering to the following specifications. Write an Employee class...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use python to create this program. 1) Employee Class Write an Employee class that keeps data...

    Use python to create this program. 1) Employee Class Write an Employee class that keeps data attributes for the following pieces of information: Note: For all classes, the attributes must be hidden Employee Name Employee Number Hire Date Create accessors and mutators Attributes should be hidden. Create a class attribute that determines a standard pay rate adjustment 4% for raises 2) ProductionWorker Class Write a class named ProductionWorker that is a subclass of Employee that holds the following attributes .Shift...

  • Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for...

    Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for the following data: • Employee name • Employee number Next, create a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have properties to hold the following data: • Shift number (an integer, such as 1, 2, or 3) • Hourly pay rate The workday is divided into two shifts: day and night. The Shift property will hold an...

  • JAVA HELP Design a class named Employee. The class should keep the following information in fields:...

    JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...

  • Design a class named Employee. The class should keep the following information in

    WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...

  • (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

    (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...

  • (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

    (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...

  • Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main()...

    Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it...

  • C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab...

    C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab9b.cpp to the project. Copy and paste the code is listed below: Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information: Shift (an integer) Hourly pay rate (a double) // Specification file for the ProductionWorker Class #ifndef PRODUCTION_WORKER_H #define PRODUCTION_WORKER_H #include "Employee.h" #include <string> using namespace std; class ProductionWorker...

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string...

    Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT