diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-18 16:37:02 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-18 16:37:02 +0200 |
commit | 4cb7ca42003c177e3acc80075d7594e555966106 (patch) | |
tree | d2f5836d70a1fa2dc1d18c4fb59f1bf1f2f91f5a /ToggleMuseumPauseCommand.cpp | |
parent | d8289105193707daede1a5b59137f18e20f20aeb (diff) |
fix command design pattern
Diffstat (limited to 'ToggleMuseumPauseCommand.cpp')
-rw-r--r-- | ToggleMuseumPauseCommand.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ToggleMuseumPauseCommand.cpp b/ToggleMuseumPauseCommand.cpp index 57176af..bdd2ef6 100644 --- a/ToggleMuseumPauseCommand.cpp +++ b/ToggleMuseumPauseCommand.cpp @@ -1,13 +1,17 @@ #include "ToggleMuseumPauseCommand.h" #include "Museum.h" -void ToggleMuseumPauseCommand::set(bool paused) { - Museum & museum = this->get_museum(); - museum.set_pause(paused); +ToggleMuseumPauseCommand::ToggleMuseumPauseCommand(Museum & m) : museum(m) { + this->toggle = true; } -void ToggleMuseumPauseCommand::toggle() { - Museum & museum = this->get_museum(); - museum.set_pause(!museum.get_pause()); +ToggleMuseumPauseCommand::ToggleMuseumPauseCommand(Museum & m, bool set) : museum(m) { + this->toggle = false; + this->value = set; +} + +void ToggleMuseumPauseCommand::execute() { + if (this->toggle) this->value = !this->museum.get_pause(); + this->museum.set_pause(this->value); } |