Question: Write class called Person that implements IPerson. Define a protected field named money of type int. Implement the payMoney method as follows. Given input integer

Write class called Person that implements IPerson. Define a protected field named money of type int. Implement  the  payMoney  method as  follows. Given  input  integer  toPay,  your  method  should decrease money by toPay and return the new value of money. Add a default constructor that sets money to 10000 (10000 = $100.00). Write getter for money named getMoney.

Exercise 3

Write a class called Employee that extends Person. Define a private integer field called employeeID.  Write constructor that accepts as input an integer called employeeID. Your constructor should call Person's constructor

so that money is still initialized (hint: super). Set the field employeeID to the parameter employeeID (hint: this). Override  the payMoney method. Remember  to  use  the @Override  annotation. Employees  only pay half. Before subtracting the amount to pay from money, divide toPay by 2, rounding down. For example, if I have 500 and am asked to pay 21, I will only pay 10 because I am an employee, making my new total 490). Hint: The Math class has a method that can help with rounding. Implement  a  static  method addMoney(I Person person,  int  amount).  This  method  should  add amount to the money of the given person. Write a getter for employeeID named getEmployeeID

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Java class Person that implements IPerson public class Person implements IPerson protected int money ... View full answer

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 Programming Questions!