Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 3 - Inheritance and polymorphism *In addition to code please provide screenshot(s) of the output for your program(s). Part 1 Inheritance Create a Rental

Program 3 - Inheritance and polymorphism *In addition to code please provide screenshot(s) of the output for your program(s).

Part 1 Inheritance

Create a Rental class for a company the rents moving trucks for people with the following 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 gets and sets as well as a 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. Make a payRental() method in this class that multiplies the number or days times $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 get and set for the weekend rate. Make a payRental() method in this class that multiplies the number or days times the weekend rate and adds the additional fees and prints this value for the user.

Part 2 polymorphism

Make test code in a separate class in its main() to run the program with four different customers, two should be doing weekday rentals and two should be doing weekend rentals. Put all four of them in an Array or ArrayList of type Rental, and loop through them polymorphically to print all four amounts they will owe with payRental() in a row for the user.

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

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago