Create a class named Movie that can be used with your video rental business. The
ID: 3837339 • Letter: C
Question
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 appropriate accessory and mutate 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 S2/day. Test your classes from a main method.Explanation / Answer
public class Driver
{
public static void main(String[] args)
{
Movie test1 = new Movie("test1", 1, "PG");
Movie test2 = new Action("test2", 2, "G");
Movie test3 = new Comedy("test3", 3, "PG-13");
Movie test4 = new Drama("test4", 4, "R");
System.out.println(test1.getID()+" "+test1.getTitle()+" "+test1.getRating()+" "+test1.calcLateFees(1));
System.out.println(test2.getID()+" "+test2.getTitle()+" "+test2.getRating()+" "+test2.calcLateFees(2));
System.out.println(test3.getID()+" "+test3.getTitle()+" "+test3.getRating()+" "+test3.calcLateFees(3));
System.out.println(test4.getID()+" "+test4.getTitle()+" "+test4.getRating()+" "+test4.calcLateFees(4));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.