#include <iostream>
#include <string>
class DVDPlayer {
public:
void on() { std::cout << "DVD Player turned on" << std::endl; }
void off() { std::cout << "DVD Player turned off" << std::endl; }
void play(const std::string& movie) {
std::cout << "Playing movie: " << movie << std::endl;
}
void stop() { std::cout << "Stopping playback" << std::endl; }
};
class Projector {
public:
void on() { std::cout << "Projector turned on" << std::endl; }
void off() { std::cout << "Projector turned off" << std::endl; }
void setInput(const std::string& input) {
std::cout << "Projector input switched to: " << input << std::endl;
}
};
class SoundSystem {
public:
void on() { std::cout << "Sound system turned on" << std::endl; }
void off() { std::cout << "Sound system turned off" << std::endl; }
void setVolume(int level) {
std::cout << "Volume set to: " << level << std::endl;
}
void setMode(const std::string& mode) {
std::cout << "Sound mode: " << mode << std::endl;
}
};
class Lights {
public:
void dim(int level) { std::cout << "Lights dimmed to: " << level << "%" << std::endl; }
void on() { std::cout << "Lights turned on" << std::endl; }
};
class HomeTheaterFacade {
private:
DVDPlayer dvd_;
Projector projector_;
SoundSystem sound_;
Lights lights_;
public:
HomeTheaterFacade() = default;
void watchMovie(const std::string& movie) {
std::cout << "===== Preparing to watch movie =====" << std::endl;
lights_.dim(20);
projector_.on();
projector_.setInput("DVD");
sound_.on();
sound_.setMode("Cinema Mode");
sound_.setVolume(8);
dvd_.on();
dvd_.play(movie);
std::cout << "===== Enjoy the movie! =====\n" << std::endl;
}
void endMovie() {
std::cout << "===== Ending movie =====" << std::endl;
dvd_.stop();
dvd_.off();
sound_.off();
projector_.off();
lights_.on();
std::cout << "===== System turned off =====\n" << std::endl;
}
};
int main() {
HomeTheaterFacade homeTheater;
homeTheater.watchMovie("Interstellar");
homeTheater.endMovie();
return 0;
}