Implement facade for carsystem
This commit is contained in:
parent
b6301771be
commit
e07e4116fc
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.pattern.facade;
|
||||||
|
|
||||||
|
import com.baeldung.pattern.facade.carsystem.*;
|
||||||
|
|
||||||
|
public class CarEngineFacade {
|
||||||
|
private static final Integer DEFAULT_COOLING_TEMP = 90;
|
||||||
|
private static final Integer MAX_ALLOWED_TEMP = 50;
|
||||||
|
private FuelInjector fuelInjector = new FuelInjector();
|
||||||
|
private AirFlowController airFlowController = new AirFlowController();
|
||||||
|
private Starter starter = new Starter();
|
||||||
|
private CoolingController coolingController = new CoolingController();
|
||||||
|
private CatalyticConverter catalyticConverter = new CatalyticConverter();
|
||||||
|
|
||||||
|
public void startEngine(){
|
||||||
|
fuelInjector.on();
|
||||||
|
airFlowController.takeAir();
|
||||||
|
fuelInjector.on();
|
||||||
|
fuelInjector.inject();
|
||||||
|
starter.start();
|
||||||
|
coolingController.setTemperatureUpperLimit(DEFAULT_COOLING_TEMP);
|
||||||
|
coolingController.run();
|
||||||
|
catalyticConverter.on();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopEngine(){
|
||||||
|
fuelInjector.off();
|
||||||
|
catalyticConverter.off();
|
||||||
|
coolingController.cool(MAX_ALLOWED_TEMP);
|
||||||
|
coolingController.stop();
|
||||||
|
airFlowController.off();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue