Given the provided class, please make the following modifications. class Employee: def __init__(self, name, number): self.name = name self.number = number class ProductionWorker(Employee): def __init__(self, name, number, shift_number, employee_number): Employee.__init__(self, name, number) self.shift_number = shift_number self.employee_number = employee_number # Create an instance of the ProductionWorker class and test it employee1 = ProductionWorker("John Doe", 1234, 2, 5678) print(employee1.name)
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Given the provided class, please make the following modifications.
class Employee:
def __init__(self, name, number):
self.name = name
self.number = number
class ProductionWorker(Employee):
def __init__(self, name, number, shift_number, employee_number):
Employee.__init__(self, name, number)
self.shift_number = shift_number
self.employee_number = employee_number
# Create an instance of the ProductionWorker class and test it
employee1 = ProductionWorker("John Doe", 1234, 2, 5678)
print(employee1.name)
print(employee1.number)
print(employee1.shift_number)
print(employee1.employee_number)
Write a class that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object's data attributes. Store the data in the object, then use the object's accessor methods to retrieve it and display it on the screen.
Step by step
Solved in 4 steps with 2 images