The finished class is given below.
MusicVideo Class
The toString() method for MusicVideo uses super.toString().
It does not have to be the first statement.
class Video
{
// stuff omitted
. . .
public void toString()
{
return title + ", " + length + " min. available:" + avail ;
}
. . .
}
class MusicVideo extends Video
{
private String artist;
private String category;
// constructor
public MusicVideo ( String ttl, int len, String art, String cat )
{
super( ttl, len );
artist = art;
category = cat;
}
public String toString()
{
return super.toString() + "artist:" + artist + " style: " + category ;
}
// Setters and Getters
public String getArtist() { return artist; }
public String getCategory() { return category; }
}
Would the following toString() method work in MusicVideo ?
public String toString()
{
return title + length + " min. available:" + avail + "\nartist:" + artist + " style: " + category ;
}