Add classes of complex car subsystem
This commit is contained in:
parent
b864ae9ded
commit
b6301771be
|
@ -0,0 +1,19 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AirFlowController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AirFlowController.class);
|
||||
private AirFlowMeter airFlowMeter = new AirFlowMeter();
|
||||
|
||||
public void takeAir() {
|
||||
airFlowMeter.getMeasurements();
|
||||
LOGGER.info("Air provided!");
|
||||
}
|
||||
|
||||
public void off() {
|
||||
LOGGER.info("Air controller switched off.");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AirFlowMeter {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AirFlowMeter.class);
|
||||
|
||||
public void getMeasurements() {
|
||||
LOGGER.info("Getting air measurements...");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CatalyticConverter {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CatalyticConverter.class);
|
||||
|
||||
public void on() {
|
||||
LOGGER.info("Catalytic Converter switched on!");
|
||||
}
|
||||
|
||||
public void off() {
|
||||
LOGGER.info("Catalytic Converter switched off!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CoolingController {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CoolingController.class);
|
||||
private static final Integer DEFAULT_RADIATOR_SPEED = 10;
|
||||
|
||||
private Integer temperatureUpperLimit;
|
||||
private Radiator radiator = new Radiator();
|
||||
private TemperatureSensor temperatureSensor = new TemperatureSensor();
|
||||
|
||||
public void setTemperatureUpperLimit(Integer temperatureUpperLimit) {
|
||||
LOGGER.info("Setting temperature upper limit to {}", temperatureUpperLimit);
|
||||
this.temperatureUpperLimit = temperatureUpperLimit;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
LOGGER.info("Cooling Controller ready!");
|
||||
radiator.setSpeed(DEFAULT_RADIATOR_SPEED);
|
||||
}
|
||||
|
||||
public void cool(Integer maxAllowedTemp) {
|
||||
LOGGER.info("Scheduled cooling with maximum allowed temperature {}", maxAllowedTemp);
|
||||
temperatureSensor.getTemperature();
|
||||
radiator.on();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
LOGGER.info("Stopping Cooling Controller...");
|
||||
radiator.off();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FuelInjector {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FuelInjector.class);
|
||||
|
||||
private FuelPump fuelPump = new FuelPump();
|
||||
|
||||
public void on(){
|
||||
LOGGER.info("Fuel injector ready to inject fuel.");
|
||||
}
|
||||
|
||||
public void inject() {
|
||||
fuelPump.pump();
|
||||
LOGGER.info("Fuel injected.");
|
||||
}
|
||||
|
||||
public void off() {
|
||||
LOGGER.info("Stopping Fuel injector...");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class FuelPump {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FuelPump.class);
|
||||
|
||||
public void pump() {
|
||||
LOGGER.info("Fuel Pump is pumping fuel...");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Radiator {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Radiator.class);
|
||||
|
||||
public void on(){
|
||||
LOGGER.info("Radiator switched on!");
|
||||
}
|
||||
|
||||
public void off(){
|
||||
LOGGER.info("Radiator switched off!");
|
||||
}
|
||||
|
||||
public void setSpeed(Integer speed){
|
||||
LOGGER.info("Setting radiator speed to {}",speed);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Starter {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Starter.class);
|
||||
|
||||
public void start() {
|
||||
LOGGER.info("Starting...");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.baeldung.pattern.facade.carsystem;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TemperatureSensor {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TemperatureSensor.class);
|
||||
|
||||
public void getTemperature(){
|
||||
LOGGER.info("Getting temperature from the sensor...");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue