Here is the code:
class thingsToRent
{
private static HashMap thingsToRent = new HashMap();
static
{
thingsToRent.put("V-1", new String( "Zumba workout video" ) );
thingsToRent.put("V-2", new String( "Pumping Iron video" ) );
}
public static String get( String serialEntered )
{
This is where I need to return the rental string such as Zumba workout or Pumping Iron,
What do I say where I have the ?
return ?;
I have tried return serialEntered but that just gives me the V-1 or V-2 which I
entered into the console using a scanner
}
}
class Video extends Thing
{
public Video( String serialEntered )
{
super( serialEntered );
}
public void getDescription( String serialEntered )
{
String theRentalFound = (String)thingsToRent.get( serialEntered );
if ( theRentalFound == null )
{
throw new IllegalArgumentException("Serial Number not found (" + serialEntered + ")");
}
else
{
System.out.println( "Video: " + theRentalFound );
}
}
}
will serve the purpose but you don’t need that because you have already achieved that in your code.