Question: PYTHON PLS 1a. Write a class named Employee that supports methods: __init__(): Constructor that takes as input the employees name and pay rate. getRate(): Returns

PYTHON PLS 1a. Write a class named Employee that supports methods:

  • __init__(): Constructor that takes as input the employees name and pay rate.
  • getRate(): Returns the employees current wage
  • changeRate(): Takes as an argument the new rate and changes the employees rate to this new number
  • pay(): Takes the number of hours worked as input and prints Not Implemented
  • __str__: prints as shown below.

Example: >>> e1 = Employee('Chris', 15)

>>> e1.getRate()

15

>>> e1.changeRate(20)

>>> e1.getRate()

20

>>> e1.pay(40)

Not implemented

>>> print(e1)

My name is Chris.

I am an employee with an hourly rate of 20.

>>>

1b. Now write a class named SalariedEmployee as a subclass of Employee that inherits all the attributes of Employee and also:

  1. extends the Employee __init__ constructor to take, as input, numberOfYears the employees has been with the company,
  2. supports method bonus that takes number value bonusPercent (a decimal) as input. The method calculates and returns the current bonus: numberOfYears*40*rate*bonusPercent
  3. overloads the __str__ operator so it behaves as shown below.

>>> e2 = SalariedEmployee('Elizabeth', 20, 15)

>>> e2.pay(40)

800

>>> e2.bonus(.2)

2400.0

>>> print(e2)

My name is Elizabeth.

I am a salaried employee with an hourly rate of $20 with a bonus = $2400.00.

I have been with the company for 15 years.

>>> e2.changeRate(30)

>>> e2.pay(40)

1200

>>> e2.bonus(.2)

3600.0

>>> print(e2)

My name is Elizabeth.

I am a salaried employee with an hourly rate of $30 and a bonus = $3600.00.

I have been with the company for 15 years.

>>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!