Smart house

Report a typo

Imagine that you live in a SmartHouse that has three subsystems from the box: StereoSystem, Light, and Bathroom. Your SmartHouse can do some pretty cool things when you come home:

1) Turn on your favorite song

2) Turn on the lights with your favorite color

3) Fill the bath with your favorite water level and temperature

We will set the favorites for you, and your task is to write the subsystems code.

Sample Input 1:

Sample Output 1:

StereoSystem on
Favorite song is playing! Queen - Killer Queen
The tub is being filled
Temperature: 35℃
Water level: 60%
Lights on
Color temperature is: Calming blue
The tub is being drained
StereoSystem off
Lights off
Write a program in Java 17
class SmartHouseFacadeTestDrive {
public static void main(String[] args) {
StereoSystem stereoSystem = new StereoSystem();
Bathroom bathroom = new Bathroom();
Lights lights = new Lights();

SmartHouseFacade smartHouseFacade = new SmartHouseFacade(stereoSystem, bathroom, lights);

lights.setFavoriteColorTemperature("Calming blue");
stereoSystem.setFavoriteSong("Queen - Killer Queen");
bathroom.setFavoriteTemperature("35℃");
bathroom.setFavoriteLevel("60%");

smartHouseFacade.cameHome();
smartHouseFacade.leaveBathroomGoSleep();
}
}

class SmartHouseFacade {
StereoSystem stereoSystem;
Bathroom bathroom;
Lights lights;

public SmartHouseFacade(StereoSystem stereoSystem, Bathroom bathroom, Lights lights) {
this.stereoSystem = stereoSystem;
this.bathroom = bathroom;
this.lights = lights;
}

public void cameHome() {
stereoSystem.on();
bathroom.fill();
lights.on();
}

public void leaveBathroomGoSleep() {
___

Create a free account to access the full topic