Question: Programming Question 3 please Explain, Page Number 518(Chapter 8) of the Book Absolute Java 6th Edition by Walter Savitch public class Question3Rental { private Rental[]


![private Rental[] rentals; /** * Constructor sets the size of the array.](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f51c80f1157_64866f51c8084d20.jpg)
Programming Question 3 please Explain, Page Number 518(Chapter 8) of the Book "Absolute Java" 6th Edition by Walter Savitch
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()
{
/eed 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
}
}
2. Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion Picture Association of America (MPAA) rating (e.g., Rated G, PG-13, R), ID Number, and movie title with appropri- ate accessor and mutator methods. Also create an equals () method that over- rides object's equals() method, where two movies are equal if their ID number is identical. Next, create three additional classes named Action, Comedy, and Drama that are derived from Movie. Finally, create an overridden method named calcLateFees that takes as input the number of days a movie is late and returns the late fee for that movie. The default late fee is $2/day. Action movies have a late fee of $3/day, comedies are $2.50/ day, and dramas are $2/day. Test your classes from a main method. 3. Extend the previous problem with a Rental class. This class should store a Movie that is rented, an integer representing the ID of the customer that rented the movie, and an integer indicating how many days late the movie is. Add a method that calculates the late fees for the rental. In your main method, create an array of type Rental filled with sample data of all types of movies. Then, create a method named lateFeesowed that iterates through the array and returns the total amount of late fees that are outstanding and Drama.java. Here, Action, Comedy, and Drama classes are derived from Movie class. Now complete the main method: public static void main(Stringll aras) Action killbill2 = new Action (0, Comedy meangirlsnew Comedy (1, Drama mystic = new Drama (2, Drama mysticcopy2new Drama (2, "Kill Bill: Volume 2", "R") "Mean Girls" "PG-13") "Mystic River", "R") "Mystic River, Second Copy", "R" // If each of the four movie objects are late by 3 days, Calculate and display //the late fees for each of the four movies. For Question 3, 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: Complete the method public double lateFene stowed) . Complete the main method as instructed by red colored comments. 2. Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion Picture Association of America (MPAA) rating (e.g., Rated G, PG-13, R), ID Number, and movie title with appropri- ate accessor and mutator methods. Also create an equals () method that over- rides object's equals() method, where two movies are equal if their ID number is identical. Next, create three additional classes named Action, Comedy, and Drama that are derived from Movie. Finally, create an overridden method named calcLateFees that takes as input the number of days a movie is late and returns the late fee for that movie. The default late fee is $2/day. Action movies have a late fee of $3/day, comedies are $2.50/ day, and dramas are $2/day. Test your classes from a main method. 3. Extend the previous problem with a Rental class. This class should store a Movie that is rented, an integer representing the ID of the customer that rented the movie, and an integer indicating how many days late the movie is. Add a method that calculates the late fees for the rental. In your main method, create an array of type Rental filled with sample data of all types of movies. Then, create a method named lateFeesowed that iterates through the array and returns the total amount of late fees that are outstanding and Drama.java. Here, Action, Comedy, and Drama classes are derived from Movie class. Now complete the main method: public static void main(Stringll aras) Action killbill2 = new Action (0, Comedy meangirlsnew Comedy (1, Drama mystic = new Drama (2, Drama mysticcopy2new Drama (2, "Kill Bill: Volume 2", "R") "Mean Girls" "PG-13") "Mystic River", "R") "Mystic River, Second Copy", "R" // If each of the four movie objects are late by 3 days, Calculate and display //the late fees for each of the four movies. For Question 3, 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: Complete the method public double lateFene stowed) . Complete the main method as instructed by red colored comments
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
