32 lines
782 B
Java
32 lines
782 B
Java
package org.util;
|
|
|
|
import org.*;
|
|
import org.model.Vehicle;
|
|
|
|
/*
|
|
* Utility class to inspect vehicles.
|
|
* Demonstrates instanceof and polymorphism.
|
|
*/
|
|
|
|
public class VehicleInspector {
|
|
|
|
public static void inspect(Vehicle v) {
|
|
|
|
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 system");
|
|
}
|
|
else if (v instanceof SportsCar){
|
|
System.out.println("Check brakes and performance");
|
|
}
|
|
else if (v instanceof GasCar){
|
|
System.out.println("Check engine and oil");
|
|
}
|
|
}
|
|
}
|