From 4cb7ca42003c177e3acc80075d7594e555966106 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 18 Oct 2024 16:37:02 +0200 Subject: fix command design pattern --- TimeTravelCommand.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'TimeTravelCommand.cpp') diff --git a/TimeTravelCommand.cpp b/TimeTravelCommand.cpp index 34468c0..44320c9 100644 --- a/TimeTravelCommand.cpp +++ b/TimeTravelCommand.cpp @@ -1,11 +1,14 @@ #include "TimeTravelCommand.h" #include "Museum.h" -void TimeTravelCommand::forwards() { - this->get_museum().skip_forward(); +TimeTravelCommand::TimeTravelCommand(Museum & m, bool forwards) : museum(m) { + this->forwards = forwards; } -void TimeTravelCommand::backwards() { - this->get_museum().skip_backward(); +void TimeTravelCommand::execute() { + if (this->forwards) + this->museum.skip_forward(); + else + this->museum.skip_backward(); } -- cgit v1.2.3