complete inspect method in VehicleInspector class
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package org.util;
|
||||
|
||||
import org.*;
|
||||
import org.model.ElectricCar;
|
||||
import org.model.GasCar;
|
||||
import org.model.SportsCar;
|
||||
import org.model.Vehicle;
|
||||
|
||||
/*
|
||||
* Utility class to inspect vehicles.
|
||||
* Demonstrates instanceof and polymorphism.
|
||||
*/
|
||||
|
||||
|
||||
public class VehicleInspector {
|
||||
|
||||
@@ -14,9 +14,14 @@ public class VehicleInspector {
|
||||
|
||||
v.basicInfo();
|
||||
|
||||
// TODO:
|
||||
// If ElectricCar → print "Check battery system"
|
||||
// If SportsCar → print "Check brakes and performance"
|
||||
// If GasCar → print "Check engine and oil"
|
||||
if (v instanceof ElectricCar) {
|
||||
System.out.println("Check battery service");
|
||||
}
|
||||
else if (v instanceof SportsCar) {
|
||||
System.out.println("Check brakes and performance");
|
||||
}
|
||||
else if (v instanceof GasCar) {
|
||||
System.out.println("Check engine and oil");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user