Question: Java Eclipse project: Write the code for class RentalItem . This class has three private data members: id of int type, description of String type,

Java Eclipse project:

Write the code for class RentalItem. This class has three private data members: id of int type, description of String type, and processingFee of double type. Provide the default constructor and the constructor with all parameters. Provide a getter and setter for each data member. All data are private and all methods are public.

/** RentalItem.java */

Code an interface named Rentable, which contains one abstract method named calcRentalFee(), which return double type and takes no formal parameter.

/** Rentable*/

Write a subclass Car that extends from RentalItem. This class has two private data: mile travelled of int type, and charges per mile of double type. Provide constructors and getters and setters as usual. Provide an effector that overrides the abstract method in interface Rentable. The rental fee of a car is calculated by adding the processing fee to the product of multiplying miles travelled with charge per mile.

/** Car.java */

Write a subclass Tool that extends from RentalItem. This class has two private data: days rent of int type, and daily rental fee of double type. Provide constructors and getters and setters as usual. Provide an effector that overrides the abstract method in interface Rentable. The rental fee of a tool is calculated by adding the processing fee to the product of multiplying days rent with daily rental fee.

/** Tool.java */

Write an application file named JohnDoeTest.java, which has a main method. This main creates an array of RentalItem class type with a size of 4. Populate this array with two instances of car objects and two instances of tool objects, and in that order. Use constructor that has all parameters.

Then in the main method, use a loop to navigate through this array, and for each loop iteration, output the id, description, and rental fee of each item.

Use another loop to calculate the total rental fee of all items in the array, and after the loop finishes, output the total rental fee.

/** JohnDoeTest.java*/

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!