CatalogItem Class
CatalogItem is a generic class that will take two type parameters
T
and S
. T
will represent the type
of a CatalogItem's ID and will be bounded by the Comparable interface.
S
will represent the type of a CatalogItem's contained object
and will be bounded by the Media interface that we have created.
CatalogItem must also implement the Comparable interface itself so that we
may sort CatalogItems.
-
Instance variables: Declare a variable,
catalogID
, of typeT
and a contained object,media
, of typeS
. -
Constructor: Take in arguments of type
T
andS
and initializecatalogID
andmedia
with these values. -
compareTo Method: Write a compareTo method that simply returns the the
compareTo of the calling object's
catalogID
and the argument object'scatalogID
. Why can we assume thatcatalogID
will have a compareTo method? -
toString Method: Write a toString method that returns the concatenation of
catalogID's
toString with the return values formedia's
getCreator, getTitle, and getYear methods. Why can we assume thatmedia
will have these methods?