Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java create a Rental class for a company who rents moving trucks for people with the following 3 attributes: name (of type string), number

In Java create a Rental class for a company who rents moving trucks for people with the following 3 attributes: name (of type string), number of days (of type integer), and additional fees (of type double). [The additional fees are for things like moving boxes purchased as part of the rental.] Make all the getters and setters as well as a full constructor for this class that takes all three variables and sets them. Make an abstract method called payRental() in this class as well.

Create a WeekDayRental class that inherits from the Rental and takes all three values in its constructor and passes them to the parent. Override the payRental() method in this class that multiplies the number of days by $79 [fixed amount the company advertises] and adds the additional fees and prints this value for the user.

Create a WeekendRental class with a weekend rate (of type double) that inherits from the Rental and takes this value as well as the three values for a Rental in its constructor and passes them to the parent. Make a getter and setter for the weekend rate. Override the payRental() method in this class that multiplies the number or days by the weekend rate and adds the additional fees and prints this value for the user.

Make test code in a separate class, RentalTest to test the Rental class and its two subclasses. In its main() methods, create an array of 4 Rental customers, two of them should be doing weekday rentals and another two should be doing weekend rentals, loop through the array so each element polymorphically calls payRental method and prints the rental amount.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago

Question

=+j Describe an effective crisis management program.

Answered: 1 week ago