package prototype;
import abstractFactory.FleetFactory;
import abstractFactory.FleetRun;
import abstractFactory.americanFleet.CityJet;
import abstractFactory.americanFleet.Dodge;
import abstractFactory.americanFleet.GeneralMotorsTruck;
import abstractFactory.rusFleet.Kamaz;
import abstractFactory.rusFleet.Liaz;
import abstractFactory.rusFleet.Vaz2110;
public class PrototypeFleetRun extends FleetRun {
protected String planFile =
"abstractFactory/fleet.properties";
public static void main
(String[] args
) { FleetRun program = new FleetRun();
// get the fleet plan
try {
program.ReadPlan();
System.
out.
println("Problems with config file: " + program.
getPlanFile());
}
// create definite factory
FleetFactory factory = program.GetFactory(program.getPlan().getProperty("factory"));
// create fleet using created factory
program.CreateFleet(factory);
System.
out.
println(program.
getMyFleet());
}
public FleetFactory GetFactory
(String id
) { if ("ru".equals(id)) {
return new PrototypeFleetFactory(
new Vaz2110("empty", 12, true),
new Liaz("empty", 20, true),
new Kamaz("empty", 53, 8, true));
} else {
return new PrototypeFleetFactory(
new Dodge("empty", 5, false),
new CityJet("empty", 42),
new GeneralMotorsTruck("empty", 4, false, true));
}
}
}