newbie doing Java homework here. I have one class named Album which contains the following constructors:
public class Album {
private String title;
private String artist;
private String genre;
private Song favoriteTrack;
private int trackNumber;
private static int numAlbums;
//Constructors
public Album(String title, Song favoriteTrack, int trackNumber) {
this.title = title;
this.favoriteTrack = favoriteTrack;
this.trackNumber = trackNumber;
artist = favoriteTrack.getArtist();
genre = favoriteTrack.getGenre();
numAlbums++;
}
public Album(String title, Song favoriteTrack) {
this(title, favoriteTrack, 1);
}
...}
And then I have a second class MusicCollection which instantiates the Album class thrice, within its main method…
public static void main (String[] args) {...
Album album1 = new Album("Debut", "Venus as a Boy", 3);
Album album2 = new Album("Homework", "Around the World", 7);
Album album3 = new Album("Ghost in the Machine", "Invisible Sun", 3);
...}
However, when I attempt to compile MusicCollection.java, I get the error:
cannot find symbol
symbol : constructor Album(java.lang.String,java.lang.String,int)
location : class Album
for each time I try to call the constructor.
The classes Album and MusicCollection ARE in the same directory, and Album.java compiles.
I imagine I’m doing something silly, but I can’t figure this out.
Any help would be much appreciated!
The second argument of the constructor you defined is
Song, notString, but in your main, you try to instantiate it with aStringas a second argument.