class TV {
turnOn() {
console.log('Turning on TV');
}
turnOff() {
console.log('Turning off TV');
}
}
class SoundSystem {
turnOn() {
console.log('Turning on sound system');
}
turnOff() {
console.log('Turning off sound system');
}
setVolume(level) {
console.log(`Setting sound system volume to ${level}`);
}
}
class DVDPlayer {
turnOn() {
console.log('Turning on DVD player');
}
turnOff() {
console.log('Turning off DVD player');
}
play(movie) {
console.log(`Playing ${movie} on DVD player`);
}
}
class HomeTheaterFacade {
constructor(tv, soundSystem, dvdPlayer) {
this.tv = tv;
this.soundSystem = soundSystem;
this.dvdPlayer = dvdPlayer;
}
watchMovie(movie) {
console.log(`Watching ${movie}...`);
this.tv.turnOn();
this.soundSystem.turnOn();
this.soundSystem.setVolume(10);
this.dvdPlayer.turnOn();
this.dvdPlayer.play(movie);
}
stopMovie() {
console.log('Stopping movie...');
this.tv.turnOff();
this.soundSystem.turnOff();
this.dvdPlayer.turnOff();
}
}
const tv = new TV();
const soundSystem = new SoundSystem();
const dvdPlayer = new DVDPlayer();
const homeTheater = new HomeTheaterFacade(tv, soundSystem, dvdPlayer);
homeTheater.watchMovie('Star Wars');
homeTheater.stopMovie();