The finished class is given below.
MusicVideo
Class
The toString()
method for MusicVideo
can use super.toString()
where ever it needs to.
class Video
{
// stuff omitted here
public void toString()
{
return title + ", " + length + " min. available:" + avail ;
}
}
class MusicVideo extends Video
{
String artist;
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 ;
}
}
You may have noticed a major design flaw in the definitions of these classes — none has a price! Say that it was your job to fix this problem. What changes will you make?