Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you will create Rental.java file to implement the Rental Class. Then, create another demo class (a Demo class Question3Rental is given below) to test the

you will create Rental.java file to implement the Rental Class.

Then, create another demo class (a Demo class Question3Rental is given below) to test the Rental class. In Question3Rental:

1. Complete the method public double lateFeesOwed().

2. Complete the main method as instructed by red colored comments.

( i have all the other class done ex. rental, movies.. i just need help with these 2 problems, the double latefeesowed and the main method missing part... anyone help??? in java please..

public class Question3Rental

{

private Rental[] rentals;

/**

* Constructor sets the size of the array.

*/

public Question3Rental(int numRentals)

{

rentals = new Rental[numRentals];

}

/**

* setRental stores a reference to a Rental object

* at the specified index.

* @param rental The rental object to put in the array

* @param index the position in the array to place the object

*/

public void setRental(Rental rental, int index)

{

this.rentals[index] = rental;

}

/**

* Return array of rentals

* @return Rental[] array of rentals

*/

public Rental[] getRentals()

{

return this.rentals;

}

/**

* Iterate through the rental array and calculate

* the total amount of late fees.

*/

public double lateFeesOwed()

{

//need to complete this method

}

/** ======================

* main method.

* In main we simply create some sample movies and output the late fees.

* ======================

*/

public static void main(String[] args)

{

Action killbill2 = new ActionMovie(0, "Kill Bill: Volume 2", "R");

Comedy meangirls = new ComedyMovie(1, "Mean Girls", "PG-13");

Drama mystic = new DramaMovie(2, "Mystic River", "R");

Question3Rental JoesRentals = new Question3Rental(3); // Joe is ID #1

Rental rental1 = new Rental(killbill2, 1);

Rental rental2 = new Rental(meangirls, 1);

Rental rental3 = new Rental(mystic, 1);

JoesRentals.setRental(rental1, 0); // Add rentals to array

JoesRentals.setRental(rental2, 1);

JoesRentals.setRental(rental3, 2);

// Make each movie 2 days late

// Calculate and display the total late fees

}

}

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

Define Law of Demand.

Answered: 1 week ago