Hi I am trying to make a movie database. Have decided to use arraylist as we cannot use arrays. It will have 4 classes, Movie, MovieDatabase, Playlist and Interface. I want the to add Movie objects from my Movie class into an Arraylist in the Moviedatabase and then be able to add and remove them from the interface. I am getting lots of errors saying it can't find the variables. I used another similar question as a template and can't figure out why it won't compile. Here is my Movie Class
public class Movie
{
private String name, director;
private int fileSize, duration;
public Movie()
{
name = "";
director = "";
fileSize = 0;
duration = 0;
}
Movie(String newName, String newDirector, int newfileSize, int newDuration)
{
this.name = newName;
this.director = newDirector;
this.fileSize = newfileSize;
this.duration = newDuration;
}
public void setName(String newName)
{
name = newName;
}
public void setDirector(String newDirector)
{
director = newDirector;
}
public void setfileSize(int newfileSize)
{
fileSize = newfileSize;
}
public void setDuration(int newDuration)
{
duration = newDuration;
}
public String getName()
{
return name;
}
public String getDirector()
{
return director;
}
public int getfileSize()
{
return fileSize;
}
public int getDuration()
{
return duration;
}
}
And the MovieDatabase Class
import java.util.*;
public class MovieDatabase
{ //start class
private ArrayList<Movie> list = new ArrayList<Movie>(4); //creates ArrayList
Movie newMovie = new Movie(newName, newDirector, newfileSize, newDuration); //instantiates Movie class
public void add(Movie newMovie) //method adds a new Movie object to the array list
{ //start add
list.add(newMovie);
} //end add
public void add(String newName, String newDirector, int newfileSize, int newDuration) //accepts parameters from main method to add to new object
{ //start add
newName = name;
newDirector = director;
newfileSize = fileSize;
newDuration = duration;
newMovie.setName(newName);
newMovie.setDirector(newDirector);
newMovie.setfileSize(newfileSize);
newMovie.setDuration(newDuration);
list.add(newName,newDirector,newfileSize,newDuration);
} //end add
}
//end class
Edit: Error messages
MovieDatabase.java:6: error: cannot find symbol
Movie newMovie = new Movie(newName, newDirector, newfileSize, newDuration); //instantiates Movie class
^
symbol: variable newName
location: class MovieDatabase
MovieDatabase.java:6: error: cannot find symbol
Movie newMovie = new Movie(newName, newDirector, newfileSize, newDuration); //instantiates Movie class
^
symbol: variable newDirector
location: class MovieDatabase
MovieDatabase.java:6: error: cannot find symbol
Movie newMovie = new Movie(newName, newDirector, newfileSize, newDuration); //instantiates Movie class
^
symbol: variable newfileSize
location: class MovieDatabase
MovieDatabase.java:6: error: cannot find symbol
Movie newMovie = new Movie(newName, newDirector, newfileSize, newDuration); //instantiates Movie class
^
symbol: variable newDuration
location: class MovieDatabase
MovieDatabase.java:17: error: cannot find symbol
newName = name;
^
symbol: variable name
location: class MovieDatabase
MovieDatabase.java:18: error: cannot find symbol
newDirector = director;
^
symbol: variable director
location: class MovieDatabase
MovieDatabase.java:19: error: cannot find symbol
newfileSize = fileSize;
^
symbol: variable fileSize
location: class MovieDatabase
MovieDatabase.java:20: error: cannot find symbol
newDuration = duration;
^
symbol: variable duration
location: class MovieDatabase
MovieDatabase.java:27: error: no suitable method found for add(String,String,int,int)
list.add(newName,newDirector,newfileSize,newDuration);
^
method Collection.add(Movie) is not applicable
(actual and formal argument lists differ in length)
method List.add(Movie) is not applicable
(actual and formal argument lists differ in length)
method List.add(int,Movie) is not applicable
(actual and formal argument lists differ in length)
method AbstractCollection.add(Movie) is not applicable
(actual and formal argument lists differ in length)
method AbstractList.add(Movie) is not applicable
(actual and formal argument lists differ in length)
method AbstractList.add(int,Movie) is not applicable
(actual and formal argument lists differ in length)
method ArrayList.add(Movie) is not applicable
(actual and formal argument lists differ in length)
method ArrayList.add(int,Movie) is not applicable
(actual and formal argument lists differ in length)