[...] class Car { public Engine getEngine(int fuelCapacity) { if (fuelCapacity == 11) { class OttoEngine implements Engine { private int fuelCapacity = 11; public int getFuelCapacity() { return fuelCapacity; } } return new OttoEngine(); } return null; } } [...]