Add classes of complex car subsystem

This commit is contained in:
Mariusz Kuligowski 2018-04-08 19:20:02 +02:00
parent b864ae9ded
commit b6301771be
9 changed files with 166 additions and 0 deletions

View File

@ -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.");
}
}

View File

@ -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...");
}
}

View File

@ -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!");
}
}

View File

@ -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();
}
}

View File

@ -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...");
}
}

View File

@ -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...");
}
}

View File

@ -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);
}
}

View File

@ -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...");
}
}

View File

@ -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...");
}
}