help with abstract class
in this code here im trying to display all the cars that need a raodworthy test. now there is an abstract class involved called HGV. within the vehicle class the testyears is different than the in the hgv class.
this takes affect in the method
vehicleNeedTest(currentYear)).
when i call this method it prints out if its a hgv twice and if the status is false. i understand that it is because there are 2 parts occuring.
yet i want it to the method without this happening please help
/**
* a method that will display all the details of the cars that need a roadworthy test
*/
publicvoid displayVehiclesThatNeedTest(int currentYear)
{
Set < String > keys = vehicles.keySet();
for ( String iD : keys)
{
Vehicle vehicle = vehicles.get(iD);
if( vehicleinstanceof HGV)
{
HGV hgv = (HGV)vehicle;
if(!hgv.vehicleNeedTest(currentYear))
{
System.out.println(hgv.toString());
}
}
if( !vehicle.vehicleNeedTest(currentYear))
{
System.out.println(vehicle.toString());
}
}
}

