Question: Create a class named Movie that can be used with y... Create a class n
ID: 3572092 • Letter: Q
Question
Question: Create a class named Movie that can be used with y... 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 accessor and mutator methods. Also create and equals() method that overrides Object's equals() method, where two movies are equal if their ID number is identical.Next, create three additional movie 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.
In Addition to the project create and add: All appropriate accessor and mutator methods(Getters and setters) an "equals ' method a toString method a default(noargument) constructor and Overloaded constructor A copy constructor A clone method a finalize method a dispose method
Question: Create a class named Movie that can be used with y... 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 accessor and mutator methods. Also create and equals() method that overrides Object's equals() method, where two movies are equal if their ID number is identical.
Next, create three additional movie 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.
In Addition to the project create and add: All appropriate accessor and mutator methods(Getters and setters) an "equals ' method a toString method a default(noargument) constructor and Overloaded constructor A copy constructor A clone method a finalize method a dispose method
Question: Create a class named Movie that can be used with y... 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 accessor and mutator methods. Also create and equals() method that overrides Object's equals() method, where two movies are equal if their ID number is identical.
Next, create three additional movie 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.
In Addition to the project create and add: All appropriate accessor and mutator methods(Getters and setters) an "equals ' method a toString method a default(noargument) constructor and Overloaded constructor A copy constructor A clone method a finalize method a dispose method
Explanation / Answer
public class Movie
{
private String rating;
private int ID;
private String title;
public Movie()
{
rating = " ";
ID = 0;
title = " ";
}
public Movie(String aRating, int aID, String aTitle)
{
rating = aRating;
ID = aID;
title = aTitle;
}
public String getRating()
{
return rating;
}
public void setRating(String aRating)
{
rating = aRating;
}
public int getID()
{
return ID;
}
public void setID(int aID)
{
ID = aID;
}
public String getTitle()
{
return title;
}
public void setTitle(String aTitle)
{
title = aTitle;
}
public double calcLateFees(int days)
{
return 2.0 * days;
}
public boolean equals(Object obj)
{
if(obj == null)
return false;
else if(getClass() != obj.getClass())
return false;
else
{
Movie other = (Movie)obj;
return (rating.equals(other.rating) && ID == other.ID && title.equals(other.title));
}
}
public String toString()
{
return " MPAA Rating: " + rating + " ID Number: " + ID+ " Movie Title: " + title;
}
}
// Action.java
public class Action extends Movie
{
public Action()
{
super();
}
public Action(String aRating, int aID, String aTitle)
{
super(aRating, aID, aTitle);
}
public double calcLateFees(int days)
{
return 3.0 * days;
}
}
// Comedy.java
public class Comedy extends Movie
{
public Comedy()
{
super();
}
public Comedy(String aRating, int aID, String aTitle)
{
super(aRating, aID, aTitle);
}
public double calcLateFees(int days)
{
return 2.5 * days;
}
}
// Drama.java
public class Drama extends Movie
{
public Drama()
{
super();
}
public Drama(String aRating, int aID, String aTitle)
{
super(aRating, aID, aTitle);
}
public double calcLateFees(int days)
{
return 2.0 * days;
}
}
// MovieTest.java
public class MovieTest
{
public static void main(String[] args)
{
Movie movie = new Movie("PG-13", 3691, "Norm of the North");
Action action = new Action("G", 2587, "Eye In The Sky");
Comedy comedy = new Comedy("R", 7989, "Kung Fu Panda 3");
Drama drama = new Drama("PG-13", 4563, "Batman v Superman");
System.out.println(movie);
System.out.println("Late Fee: $" + movie.calcLateFees(6));
System.out.println(action);
System.out.println("Late Fee: $" + action.calcLateFees(6));
System.out.println(comedy);
System.out.println("Late Fee: $" + comedy.calcLateFees(6));
System.out.println(drama);
System.out.println("Late Fee: $" + drama.calcLateFees(6));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.