Question: Produce the desire output. Beginning of code written:CS 2 2 6 Programming Project Create a class named Movie that can be used with your video

Produce the desire output. Beginning of code written:CS226 Programming Project
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 (G,
PG, R), the movie's ID number and title with appropriate
setter and getter methods. Also create an equals() method
that overrides the Object's equals() method, where two
movies are equal if their ID numbers are equal.
Create three additional classes named Action, Comedy, and Drama that are derived
from Movie. 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.75? day.
Add 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
representing how many days late the movie is. Include a method that calculates the
late fee for the rental.
In your main method, create an array or ArrayList of type Rental filled with sample
data for various type of movies. Then create a method called lateFeesOwed that
iterates through the array and returns the total amount of late fees outstanding.
Draw a UML diagram that illustrates the relationship between these classes.
On the day of the final exam (Wednesday, April 243:00-5:00PM) be prepa
import java.util.ArrayList;
public class Test
{
public static void main(String[] args)
{
ArrayList listOfRentals = new ArrayList();
Movie m1= new Drama("G",1, "Title1");
Movie m2= new Action("PG",2, "Title2");
Movie m3= new Comedy("G",3, "Title3");
Movie m4= new Drama("R",4, "Title4");
Movie m5= new Action("R",5, "Title5");
Rental r1= new Rental(m1,1,1);
Rental r2= new Rental(m2,2,1);
Rental r3= new Rental(m3,3,1);
Rental r4= new Rental(m4,4,1);
Rental r5= new Rental(m5,5,1);
listOfRentals.add(r1);
listOfRentals.add(r2);
listOfRentals.add(r3);
listOfRentals.add(r4);
listOfRentals.add(r5);
r1.setDaysLate(1);
r2.setDaysLate(2);
r3.setDaysLate(3);
r4.setDaysLate(4);
r5.setDaysLate(5);
double total =0;
for (int i =0; i listOfRentals.size(); i++)
{
System.out.println(listOfRentals.get(i).calculateLateFee());
}
}
}
class Movie
{
private String mpaaRating;
private int id;
private String title;
public Movie(String mpaaRatin, int id, String title)
{
this.mpaaRating = mpaaRating;
this.id = id;
this.title = title;
}
public String getMpaaRating()
{
return mpaaRating;
}
public void setMpaaRating(String mpaaRating)
{
this.mpaaRating = mpaaRating;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public double calcLateFees(int daysLate)
{
return 2* daysLate;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null || getClass()!= obj.getClass())
return false;
Movie movie =(Movie) obj;
return id == movie.id;
}
}
class Rental
{
private Movie movie;
private int customerId;
private int daysLate;
public Rental(Movie movie, int customerId, int daysLate)
{
this.movie = movie;
this.customerId = customerId;
this.daysLate = daysLate;
}
public void setDaysLate(int daysLate)
{
this.daysLate = daysLate;
}
public int getDaysLate()
{
return daysLate;
}
public double calculateLateFee()
{
return movie.calcLateFees(daysLate);
}
}
class Comedy extends Movie
{
public Comedy(String mpaaRating, int id, String title)
{
super(mpaaRating, id, title);
}
@Override
public double calcLateFees(int daysLate)
{
return 2.50* daysLate;
}
}
class Drama extends Movie
{
public Drama(String mpaaRating, int id, String title)
{
super(mpaaRating, id, title);
}
@Override
public double calcLateFees(int daysLate)
{
return 2.75* daysLate;
}
}
class Action extends Movie
{
public Action(String mpaaRating, int id, String title)
{
super(mpaaRating, id, title);
}
@Override
public double calcLateFees(int daysLate)
{
return 3.0* daysLate;
}
}
Produce the desire output. Beginning of code

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 Programming Questions!