Create a class named Movie that can be used with your video rental business. The
ID: 3571718 • 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 accessor and mutator methods. Also create an equals() method that overrides 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. You are expected to include the following: All appropriate accessor and mutator methods (getters and setters). An 'equals' method (must conform to the Person example and the object class). A 'toString' method The default and overloaded constructors A 'copy' constructor, A 'clone' method A 'finalize' method, and A 'dispose' method.Explanation / Answer
Hi,
Please see below the java classes. Please comment for any queries/feedback.
Thanks,
Anita
Movie.java
public class Movie {
public Movie(String MPAARating, String IDNumber,String title) {
this.MPAARating =MPAARating;
this.IDNumber =IDNumber;
this.title = title;
}
public Movie(Movie movie) {
this.MPAARating = movie.getMPAARating();
this.IDNumber =movie.getIDNumber();
this.title = movie.getTitle();
}
private String MPAARating;
private String IDNumber;
private String title;
public String getMPAARating() {
return MPAARating;
}
public void setMPAARating(String mPAARating) {
MPAARating = mPAARating;
}
public String getIDNumber() {
return IDNumber;
}
public void setIDNumber(String iDNumber) {
IDNumber = iDNumber;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean equals(String ID){
if(this.IDNumber.equalsIgnoreCase(ID)){
return true;
}
else{
return false;
}
}
public String toString(){
String val= "Title : "+this.getTitle() +", ID :"+this.getIDNumber()+ ", Rating : "+this.getMPAARating()+".";
return val;
}
public void finalize(){
System.out.println("Finalize called..");
}
public void dispose(){
System.out.println("Dispose called..");
}
public Object clone() throws CloneNotSupportedException{
return super.clone();
}
public double calcLateFees(){
return 2;
}
}
Action.java
public class Action extends Movie {
public Action(String MPAARating, String IDNumber,String title) {
super(MPAARating,IDNumber,title);
}
public double calcLateFees(){
return 3;
}
}
Comedy.java
public class Comedy extends Movie {
public Comedy(String MPAARating, String IDNumber,String title) {
super(MPAARating,IDNumber,title);
}
public double calcLateFees(){
return 2.50;
}
}
Drama.java
public class Drama extends Movie {
public Drama(String MPAARating, String IDNumber,String title) {
super(MPAARating,IDNumber,title);
}
public double calcLateFees(){
return 2;
}
}
MovieApp.java
public class MovieApp {
public static void main(String [] args){
//Creation Action object
Action actionMovie= new Action("G", "101", "ABC");
System.out.println("Action Movie Details: "+actionMovie.toString());
System.out.println("Late fee for Action movie is : $"+actionMovie.calcLateFees());
//Creation Comedy object
Comedy comedyMovie= new Comedy("G", "102", "DEF");
System.out.println("Comedy Movie Details: "+comedyMovie.toString());
System.out.println("Late fee for Comedy movie is : $"+comedyMovie.calcLateFees());
//Creation Drama object
Drama dramaMovie= new Drama("G", "103", "XYZ");
System.out.println("Drama Movie Details: "+dramaMovie.toString());
System.out.println("Late fee for Drama movie is : $"+dramaMovie.calcLateFees());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.