So far the video rental application has two classes:
Video
and Movie
.
Say that you wanted to create a new class,
MusicVideo
that will be like
Video
but will have two new instance variables:
artist
and category
("R&B", "Pop", "Classical", "Other" ).
Both of these will be Strings.
The MusicVideo
class will need its own
constructor and its own toString()
method.
Here is the parent class:
class Video { String title; // name of the item int length; // number of minutes boolean avail; // is the video in the store? // constructor public Video( String ttl, int lngth ) { title = ttl; length = lngth; avail = true; } public void toString() { return title + ", " + length + " min. available: " + avail ; } }
The new class looks like this:
class extends { String ; // the artist String ; // the music category // constructor will go here (skip for now) // toString method will go here (skip for now) }
Fill in the blanks.
For now, leave out the constructor and the toString()
method.