In: Computer Science
Using UML, design a class that allows you to store and print employee information: name, id, and hourly_salary. Include the appropriate mutator and accessor methods.
Write the code to create the class.
Write a test program that instantiates an employee object. After the object is created write the code to give the employee a 3% raise.
(IN PYTHON)
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.
=====================================================================
class Employee():
def __init__(self, name, id, hourly_salary):
self.__name = name
self.__id = id
self.__hourly_salary = hourly_salary
def getName(self): return self.__name
def getID(self): return self.__id
def getHourlySalary(self): return self.__hourly_salary
def incrementSalary(self, percentage):
self.__hourly_salary += self.__hourly_salary * percentage / 100
def __str__(self):
return 'Employee Name: {}, Id: {}, Hourly Salary ${:.2f}'.format(self.__name, self.__id,
self.__hourly_salary)
def main():
emp = Employee('John Doe', 123, 30)
print(emp)
print('Incrementing salary by 3% percentage')
emp.incrementSalary(3)
print(emp)
main()
====================================================================
