From b59c6baed8071c835ee2788a4190967841470702 Mon Sep 17 00:00:00 2001 From: moonleay Date: Tue, 17 Dec 2024 14:39:33 +0100 Subject: [PATCH] fix: made game quit when pressing q in maze creator --- MazeParser.cpp | 6 ++++++ main.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/MazeParser.cpp b/MazeParser.cpp index 37118f7..0499265 100644 --- a/MazeParser.cpp +++ b/MazeParser.cpp @@ -4,9 +4,11 @@ #include "MazeParser.h" +#include "Exceptions/ExitGame.h" #include "Exceptions/MalformedMaze.h" using game_exceptions::MalformedMaze; +using game_exceptions::ExitGame; namespace game { @@ -74,6 +76,10 @@ namespace game if (!cin) throw MalformedMaze("Cin failed while reading chars!"); + // Verlasse das Spiel + if (input == 'q') + throw ExitGame("Schoenen Tag noch!"); + // Kontrolliere, ob das Element in einem Labyrinth vorkommen darf if (!is_valid_maze_element(input)) throw MalformedMaze("The given input is not a valid element of a maze!"); diff --git a/main.cpp b/main.cpp index efc5103..02729ff 100644 --- a/main.cpp +++ b/main.cpp @@ -36,9 +36,9 @@ int main() // Das Labyrinth einlesen hat nicht geklappt. Gebe Fehlermeldung aus und beende das Programm. cout << "Fehler beim Einlesen des Labyrinths.\n"; return 0; - } catch (ExitGame& err) + } catch (ExitGame& _) { - cout << err.what() << "\n"; + cout << "Schoenen Tag noch!" << "\n"; }