This program introduces the concept of inheritance by creating subclasses of a M
ID: 3852812 • Letter: T
Question
This program introduces the concept of inheritance by creating subclasses of a Movie class. The program should have two classes: MoviesClass.java MoviesMainClass.java Create a class named MoviesClass. TheMoviesClass class should track the Motion Picture Association of America (MPAA) rating (eg.. Rated G. PG-13. R. etc.). ID Number, and movie title with appropriate accessor and mutator methods. Inside the MovieClass create an equals() method that overrides MovieClass equals () method, such that two movies are equal if their ID number is identical Inside the MovieClass create three additional movie rating type classes named: Action Movie Comedy Movie Drama Movie that are derived from Movie. 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 rating type. Create a method called toString() that displays all the movie object values and stales in a well formatted manner. The following are the late fees for movie rating types: Default exist2.00/day Action exist3.00/day Comedies exist2.50/day Dramas exist2.00/day. Test your classes from a main method. The main class must include driver code that tests all the objects paths. The driver code in the main class should not be prompted basedExplanation / Answer
public class MoviesClass {
private String movieRating;
private int IDnumber;
private String movieTitle;
public MoviesClass()
{
IDnumber = 0;
movieTitle = "";
}
public MoviesClass(String rating, int id, String title)
{
movieRating = rating;
IDnumber = id;
movieTitle = title;
}
// ComedyMovie.java
public class ComedyMovie extends MoviesClass
{
public ComedyMovie()
{
super();
}
public ComedyMovie(String aRating, int aID, String aTitle)
{
super(aRating, aID, aTitle);
}
public double calcLateFees(int days)
{
return 2.5 * days;
}
}
// ActionMovie.java
public class ActionMovie extends MoviesClass
{
public ActionMovie()
{
super();
}
public ActionMovie(String aRating, int aID, String aTitle) {
super(aRating, aID, aTitle);
}
public double calcLateFees(int days) {
return 3.0 * days;
}
}
//MoviesMainClass.java
public class MoviesMainClass
{
public static void main(String[] args)
{
MoviesClass movie = new MoviesClass("PG-11", 3691, "Guardians of Galaxy");
System. out.println(movie);
System.out.println("Late Fee: $" + movie.calcLateFees(6));
ActionMovie action = new ActionMovie("A", 2587, "Dejavu");
System. out.println(action);
System.out.println("Late Fee: $" + action.calcLateFees(6));
ComedyMovie comedy = new ComedyMovie("C", 7989, "Despicable me");
System. out.println(comedy);
System.out.println("Late Fee: $" + comedy.calcLateFees(6));
DramaMovie drama = new DramaMovie("PG-12", 4563, "Honey I shrunk");
System. out.println(drama);
Systemsout.printlnr Late Fee: $" + drama.calcLateFees(6));
}
}
public String getmovieRating() {
return movieRating;
}
public void setmovieRating(String rating) {
movieRating = rating;
}
public int getIDnumber() {
return IDnumber;
}
public void setIDnumber(int id) {
IDnumber = id;
}
public String getmovieTitle() {
return movieTitle;
}
public void setmovieTitle(String title) {
movieTitle = title;
}
public double calcLateFees(int days) {
return 2.0 * days; }
public boolean equals(Object movieobject) {
if(movieobject == null)
return false;
else if(getClass() ! = movieobject.getClass())
return false;
else
{
MoviesCiass other = (MoviesClass)movieobject;
return (movieRating.equals(other.movieRating) && IDnumber == other.IDnumber && movieTitle.equals(other.movieTitle));
}
}
public String toString()
{
return "/n MPAA Rating:" + movieRating + "IDNumber" + IDnumber + "Movie Title:" + movieTitle;}
}
public class DramaMovie extends MoviesClass
{
public DramaMovie()
{
super();
}
public DramaMovie(String rating, mt id, String title)
{
super(rating, id, title);
}
public double calcLateFees(int days)
{
return 2.0 * days;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.