What do they want from me?

Hello Experts,

I have this homework assignment and I'm unclear about what they want from me... I'm hoping someone will help me out here.  I've satisfied almost all of the requirements in the assignment, but the part starting with calcLateFees is confusing me.  Here is the question, verbatim.

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 (i.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.

This assignment is supposed to be about polymorphism and abstract classes, so where am I supposed to create the calcLateFees method, and what method is it overriding?  The instruction is not clear.  Someone please help!
// Here are my classes-----------------------------------------
public class Movie {
  private String Rating = "NR";
  private int ID = 0;
  private String Title = "No Title Yet";
  
  public void SetTitle(String theTitle) {
    Title = theTitle;
  }
  public String GetTitle() {
    return Title;
  }
  public void SetID(int theID) {
    ID = theID;
  }
  public int GetID() {
    return ID;
  }
  public void SetRating(String theRating) {
    Rating = theRating;
  }
  public String GetRating() {
    return Rating;
  }
  public boolean equals(int ID1, int ID2) {
    if (ID1 == ID2) {
      return true;
    } else {
      return false;
    }
  }
} //-----------------------------------------------------
 
class Action extends Movie {
  /* The instruction didn't
   * say what to do with the
   * dirived classes... */  
} //------------------------------------------------
 
class Comedy extends Movie {
 // ?
} //----------------------------------------------
 
class Drama extends Movie {
// ?
} //---------------------------------------------

Open in new window

LVL 3
fibdevAsked:
Who is Participating?
 
Gibu GeorgeConnect With a Mentor Chief Technology OfficerCommented:
return this.ID==movie.GetID();
0
 
CEHJConnect With a Mentor Commented:
Late fee calculation can go in the parent class
0
 
Gibu GeorgeChief Technology OfficerCommented:
The class movie should be abstract and should have an abstract method calcLateFees,  which takes the parameter no of days, you need to add the implementation in each of the subclasses, ie in Action, Comedy etc.

in action it will be
public int calcLateFees(int noOfDays){
return 3*noOfdays
}

also the equals method takes an object of Movie as its parameter

public boolean equals(Movie movie){
  return this.ID==movie.GetID;
}
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
CEHJConnect With a Mentor Commented:
btw, the correct pattern in Java for accessors and mutators is as follows:
public class Movie {
    private String rating;
 
    public String getRating() {
        return this.rating;
    }   
 
    public void setRating(String rating) {
        this.rating = rating;
    }   
}

Open in new window

0
 
CEHJCommented:
>>
also the equals method takes an object of Movie as its parameter

public boolean equals(Movie movie){
  return this.ID==movie.GetID;
}
>>

It actually take a parameter of type Object:
public boolean equals(Object o) {
  return this.ID==((Movie)o).ID;
}

Open in new window

0
 
Gibu GeorgeChief Technology OfficerCommented:
Okay, thax. for reminding me
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.