Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class named Movie that can be used with your video rental business. The

ID: 3835891 • 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 Assoiation 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 overridesObject'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 and 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 defualt 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.

In addition to the requirements listed in the book, 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

* A 'dispose' method

Explanation / Answer

Here is your program: -

Movie.java


public class Movie implements Cloneable{
   private String MPAArating;
   private Integer idNum;
   private String movieTitle;
  
   //Default Constructor
   Movie() {
       this.movieTitle="";
       this.idNum = 0;
       this.movieTitle ="";
   }
  
   //Overloaded Constructor
   Movie(int id, String rating, String title) {
       this.idNum = id;
       this.MPAArating = rating;
       this.movieTitle = title;
   }
  
   //Copy contructor
   Movie(Movie m) {
       this.idNum = m.getIdNum();
       this.movieTitle = m.getMovieTitle();
       this.MPAArating = m.getMPAArating();
   }
  
   //Clone Method
   public Object clone() throws CloneNotSupportedException{
       return super.clone();
   }
  
   //Finalize method
  
   @Override
   protected void finalize() throws Throwable {
      
       super.finalize();
   }
  
  
   public String getMPAArating() {
       return MPAArating;
   }
   public void setMPAArating(String mPAArating) {
       MPAArating = mPAArating;
   }
   public Integer getIdNum() {
       return idNum;
   }
   public void setIdNum(Integer idNum) {
       this.idNum = idNum;
   }
   public String getMovieTitle() {
       return movieTitle;
   }
   public void setMovieTitle(String movieTitle) {
       this.movieTitle = movieTitle;
   }
   @Override
   public int hashCode() {
       final int prime = 31;
       int result = 1;
       result = prime * result + ((idNum == null) ? 0 : idNum.hashCode());
       return result;
   }
   @Override
   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       Movie other = (Movie) obj;
       if (idNum == null) {
           if (other.idNum != null)
               return false;
       } else if (!idNum.equals(other.idNum))
           return false;
       return true;
   }
   public Double calcLateFees(int n) {
       return n*2.0;
   }
  
   public String toString() {
       return "Movie ID: "+this.idNum+", Title: "+this.movieTitle+", MPAArating:"+this.MPAArating;
   }
}

Action.java


public class Action extends Movie {
  
   public Double calcLateFees(int n) {
       return n*3.0;
   }
  
   Action() {
       super();
   }
  
   Action(String rating,int id,String title) {
       super(id,rating,title);
   }
}

Comedy.java


public class Comedy extends Movie {

   public Double calcLateFees(int n) {
       return n*2.50;
   }
  
   Comedy() {
       super();
   }
  
   Comedy(String rating,int id,String title) {
       super(id,rating,title);
   }
}

Drama.java


public class Drama extends Movie {
   public Double calcLateFees(int n) {
       return n*2.0;
   }
  
   Drama() {
       super();
   }
  
   Drama(String rating,int id,String title) {
       super(id,rating,title);
   }
}

Main.java


public class Main {
  
  
  
   public static void main(String[] args) throws Throwable {
       Movie m = new Action("PG-13",2,"Prison Escape");
       Movie m1 = new Action("PG-13",2,"PrisonEscape");
      
       Movie m2 = new Comedy("PG-13",2,"Prison Escape Drama");
      
       System.out.println("Is m and m1 same:"+m.equals(m1));
      
       Movie m3 = (Action)m1.clone();
       Movie m4 = new Movie(m3);
      
       System.out.println(m.toString());
       System.out.println(m1.toString());
       System.out.println(m2.toString());
       System.out.println(m3.toString());
       System.out.println(m4.toString());
      
       System.out.println("Finalizing....");
       m.finalize();
       m1.finalize();
       m2.finalize();
       m3.finalize();
       m4.finalize();
       System.out.println("Finalized.");
       m4.toString(); // This will print nothing as it is already finalized.
   }
}

Sample Output: -

Is m and m1 same:true
Movie ID: 2, Title: Prison Escape, MPAArating:PG-13
Movie ID: 2, Title: PrisonEscape, MPAArating:PG-13
Movie ID: 2, Title: Prison Escape Drama, MPAArating:PG-13
Movie ID: 2, Title: PrisonEscape, MPAArating:PG-13
Movie ID: 2, Title: PrisonEscape, MPAArating:PG-13
Finalizing....
Finalized.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote