Make a class called Employee with attributes for name, hours worked, and pay rate. Make a constructor that takes name, hours worked and pay rate as initializing parameters. Make a function in the class that will calculate their gross pay (multiply number of hours worked by pay rate). Make a function in the class called __str__ that prints out the name, hours worked and pay rate. Output a greeting to the user and then Prompt user to enter name, number of hours worked and pay rate. Make an instance of the employee class with the data they input. Now call the grosspay function to get the grosspay and print that out, Next call the __str__ function to print out the data in the instance (name, number of hours worked and pay rate)
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:
Make a class called Employee with attributes for name, hours worked, and pay rate. Make a constructor that takes name, hours worked and pay rate as initializing parameters. Make a function in the class that will calculate their gross pay (multiply number of hours worked by pay rate). Make a function in the class called __str__ that prints out the name, hours worked and pay rate.
Output a greeting to the user and then Prompt user to enter name, number of hours worked and pay rate. Make an instance of the employee class with the data they input. Now call the grosspay function to get the grosspay and print that out, Next call the __str__ function to print out the data in the instance (name, number of hours worked and pay rate)
Step by step
Solved in 3 steps with 2 images