Complete MusicVideo Class

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

The finished class is given below.

Complete MusicVideo Class

The show() method for MusicVideo can use super.show() where ever it needs to. It is the first statement (below) because that is where it makes the most sense.

class Video
{
  // stuff ommitted here
  public void show()
  {
    System.out.println( 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 void show()
  {
    super.show();
    System.out.println( "artist:" + artist + " style: " + category );
  }
}

QUESTION 21:

You may have noticed a major design flaw in the definitions of these classes — none has a rental price! Say that it was your job to fix this problem. What changes will you make?