53 lines
1.4 KiB
Java
53 lines
1.4 KiB
Java
package org;
|
|
|
|
import org.model.ElectricCar;
|
|
import org.model.GasCar;
|
|
import org.model.SportsCar;
|
|
import org.model.Vehicle;
|
|
import org.behavior.Serviceable;
|
|
import org.util.VehicleInspector;
|
|
|
|
public class Main {
|
|
public static void main(String[] args)
|
|
{
|
|
ElectricCar porsche = new ElectricCar("Porsche", "Taycan", 2023, 12000.0, 4, 93, 65.5);
|
|
|
|
GasCar benz = new GasCar("Mercedes-Benz", "C200", 2022, 28000.0, 5, 42.0, "Petrol");
|
|
|
|
SportsCar audi = new SportsCar("Audi", "R8", 2021, 15000.0, 2, 55.0, "Petrol", 3.1);
|
|
|
|
Vehicle[] vehicles = { porsche, benz, audi };
|
|
|
|
for (Vehicle v : vehicles)
|
|
{
|
|
v.basicInfo();
|
|
System.out.println();
|
|
}
|
|
|
|
for (Vehicle v : vehicles)
|
|
{
|
|
VehicleInspector.inspect(v);
|
|
System.out.println();
|
|
}
|
|
|
|
Serviceable[] serviceables = { porsche, benz, audi };
|
|
|
|
for (Serviceable s : serviceables)
|
|
{
|
|
Vehicle v = (Vehicle) s;
|
|
|
|
if (s.needsService(v))
|
|
{
|
|
System.out.println(v.getBrand() + " " + v.getModel() + " needs service.");
|
|
s.performService();
|
|
}
|
|
else
|
|
{
|
|
System.out.println(v.getBrand() + " " + v.getModel() + " does not need service.");
|
|
}
|
|
System.out.println();
|
|
}
|
|
System.out.println("=== Workshop Completed ===");
|
|
}
|
|
}
|