这是代码:
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 )
{
这是我需要归还租用绳索的地方,例如尊巴锻炼或抽铁,
我说什么我有?
return ?;
我试过 return serialEntered 但这只是给了我我的 V-1 或 V-2
使用扫描仪输入控制台
}
}
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 );
}
}
}