For a computer science project I have a Movie class that implements Comparable with Comedy, Action, and MovieTrilogy extending it. The problem I am having is that MovieTrilogy takes 3 Movie objects in the constructor. The MovieTrilogy class needs to have the Movie objects as instance variables which means I need to declare an abstract object. I belive what my teacher would want is to declare the MovieTrilogy object with Comedy and Action objects, but I would still need to store them as instance variables. How would I do this? The movie constructor as well as the MovieTrilogy class are atatched below.
public class MovieTrilogy extends Movie{
private Movie movie1;
private Movie movie3;
private Movie movie2;
public MovieTrilogy(Movie Movie1, Movie Movie2, Movie Movie3){
movie1 = Movie1;
movie2 = Movie2;
movie3 = Movie3;
}
And this is the movie class.
public abstract class Movie implements Comparable<Movie>{
private int Score;
private String Title;
public Movie(String title, int score){
Title = title;
Score = score;
}
public int getScore(){ return Score; }
public String getTitle(){ return Title; }
public int compareTo(Movie movie){
return this.compareTo(movie);
}
public String getGenre(){
return null;
}
public String toString(){
return Title + " with a score of " + Score;
}
}
The code below is the error it gives me trying to compile MovieTrilogy
.
MovieTrilogy.java:5: error: constructor Movie in class Movie cannot be applied to given types;
public MovieTrilogy(Movie Movie1, Movie Movie2, Movie Movie3){
^
required: String,int
found: no arguments