From b492bfb0d4cafe69edf69f196911f1b0e64c43df Mon Sep 17 00:00:00 2001 From: dawidg81 Date: Mon, 26 Jan 2026 17:15:33 +0100 Subject: added utilities; recovered custom difficulty editing --- src/utils/Utils.hpp | 11 +++++++++++ src/utils/catchInputInt.cpp | 15 +++++++++++++++ src/utils/catchReturn.cpp | 11 +++++++++++ src/utils/utils.hpp | 10 ---------- 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 src/utils/Utils.hpp create mode 100644 src/utils/catchInputInt.cpp create mode 100644 src/utils/catchReturn.cpp delete mode 100644 src/utils/utils.hpp (limited to 'src/utils') diff --git a/src/utils/Utils.hpp b/src/utils/Utils.hpp new file mode 100644 index 0000000..7df9e3d --- /dev/null +++ b/src/utils/Utils.hpp @@ -0,0 +1,11 @@ +#include + +#ifndef UTILS_HPP + +class Utils{ + public: + int catchInputInt(int input); + int catchReturn(int renum); +}; + +#endif \ No newline at end of file diff --git a/src/utils/catchInputInt.cpp b/src/utils/catchInputInt.cpp new file mode 100644 index 0000000..0dc8fc9 --- /dev/null +++ b/src/utils/catchInputInt.cpp @@ -0,0 +1,15 @@ +#include "Utils.hpp" + +#include +#include + +int Utils::catchInputInt(int input){ + std::cin >> input; + + if (std::cin.fail()) { + std::cout << "error: Input failed" << std::endl; + return 1; + } + + return 0; +} \ No newline at end of file diff --git a/src/utils/catchReturn.cpp b/src/utils/catchReturn.cpp new file mode 100644 index 0000000..c3d6722 --- /dev/null +++ b/src/utils/catchReturn.cpp @@ -0,0 +1,11 @@ +#include "Utils.hpp" + +#include +#include + +int Utils::catchReturn(int renum){ + if (renum != 0) { + std::cout << "Received error signal, sending further" << std::endl; + } + return 0; +} \ No newline at end of file diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp deleted file mode 100644 index 19ae230..0000000 --- a/src/utils/utils.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -#ifndef UTILS_HPP - -class Utils{ - public: - void input(std::string input); -}; - -#endif \ No newline at end of file -- cgit v1.2.3