Question: In the cell below, write a class to represent an employee as per following specifications: Class name: Employee Instance attributes: as defined by the items
In the cell below, write a class to represent an employee as per following specifications:
- Class name:Employee
- Instance attributes: as defined by the items in objectemployee_51i.e.employee_id,firstname, etc.
- _init_()method: should initialise instance attributes to the value of the parameters passed to the method
- set_firstname()method: to set the firstname in the instance variable to the value of the parameter passed
- get_name()method: to get the full name formatted aslastname, firstname
After having defined the class, you need to test the class and its methods to show that it works. You can do this as follows:
- Instantiate an object of the class and passemployee_51to the initialiser
- Set the firstname to something different by calling set_firstname() and passing it the appropriate parameter
Hint:
- Lab Task 4.1 - Implement a classandWeek 4 Lecture notes
employee_51 = {
"email": "..s@gmail.com",
"employee_id": 51,
"firstname": "Paul",
"lastname": "Rogers",
"title": "Mr",
"work_phone": "(02) 5829 2608"
}
# Write your code here.
# Define the class here.
# Instantiate the class and call its methods here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
