From 5241ddbfb8d812f0b75e67c718e47586b664b556 Mon Sep 17 00:00:00 2001 From: gruszczrob <=> Date: Thu, 6 Jun 2024 15:57:31 +0200 Subject: [PATCH 1/2] Implementation of Cli --- Cli/CMakeLists.txt | 14 ++++++++++++++ Cli/Cli.cpp | 19 +++++++++++++++++++ Cli/Cli.h | 25 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 Cli/CMakeLists.txt create mode 100644 Cli/Cli.cpp create mode 100644 Cli/Cli.h diff --git a/Cli/CMakeLists.txt b/Cli/CMakeLists.txt new file mode 100644 index 0000000..c998250 --- /dev/null +++ b/Cli/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.10) + +# Set the project name +project(Cli) + +# Define the Cli library +add_library(Cli STATIC + Cli.cpp + Cli.h +) + +target_include_directories(Cli PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(Cli PUBLIC DrawingEngine ClassFactory) + diff --git a/Cli/Cli.cpp b/Cli/Cli.cpp new file mode 100644 index 0000000..161215e --- /dev/null +++ b/Cli/Cli.cpp @@ -0,0 +1,19 @@ +#include "Cli.h" + +Cli::Cli(any widthI, any heightI, any wallI, any routeI) : DrawingEngine(widthI, heightI) { + writeToLogs("CLI created"); + if (!checkIfCorrect() || !setVar(wall, wallI, "wall") || !setVar(route, routeI, "route")) { + setNotCorrected(); + } +} + +void Cli::print(vector> grid) { + for (int v = 0; v < getVar("height"); v++) { + for (int i = 0; i < getVar("width"); ++i) { + char toPrint = (grid[v][i] == 0) ? getVar("route") : getVar("wall"); + cout << toPrint; + } + cout << endl; + } +} + diff --git a/Cli/Cli.h b/Cli/Cli.h new file mode 100644 index 0000000..d5ed1fb --- /dev/null +++ b/Cli/Cli.h @@ -0,0 +1,25 @@ +#ifndef CLI_H +#define CLI_H + +#include +#include +#include +#include +#include "../Logs/Logs.h" +#include "../DrawingEngine/DrawingEngine.h" + +using namespace std; + +class Cli : public DrawingEngine { +private: + shared_ptr wall = make_shared(); + shared_ptr route = make_shared(); + +public: + Cli(any widthI, any heightI, any wallI, any routeI); + + void print(vector> grid); +}; + +#endif /* CLI_H */ + From 6ad3695c843aeb9fd1669087e05d3f4004dd6339 Mon Sep 17 00:00:00 2001 From: gruszczrob <=> Date: Thu, 6 Jun 2024 16:04:51 +0200 Subject: [PATCH 2/2] improwing visual of code --- Cli/Cli.cpp | 22 +++++++++++----------- Cli/Cli.h | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cli/Cli.cpp b/Cli/Cli.cpp index 161215e..2f0a85e 100644 --- a/Cli/Cli.cpp +++ b/Cli/Cli.cpp @@ -1,19 +1,19 @@ #include "Cli.h" Cli::Cli(any widthI, any heightI, any wallI, any routeI) : DrawingEngine(widthI, heightI) { - writeToLogs("CLI created"); - if (!checkIfCorrect() || !setVar(wall, wallI, "wall") || !setVar(route, routeI, "route")) { - setNotCorrected(); - } + writeToLogs("CLI created"); + if (!checkIfCorrect() || !setVar(wall, wallI, "wall") || !setVar(route, routeI, "route")) { + setNotCorrected(); + } } void Cli::print(vector> grid) { - for (int v = 0; v < getVar("height"); v++) { - for (int i = 0; i < getVar("width"); ++i) { - char toPrint = (grid[v][i] == 0) ? getVar("route") : getVar("wall"); - cout << toPrint; - } - cout << endl; - } + for (int v = 0; v < getVar("height"); v++) { + for (int i = 0; i < getVar("width"); ++i) { + char toPrint = (grid[v][i] == 0) ? getVar("route") : getVar("wall"); + cout << toPrint; + } + cout << endl; + } } diff --git a/Cli/Cli.h b/Cli/Cli.h index d5ed1fb..c4c041d 100644 --- a/Cli/Cli.h +++ b/Cli/Cli.h @@ -12,13 +12,13 @@ using namespace std; class Cli : public DrawingEngine { private: - shared_ptr wall = make_shared(); - shared_ptr route = make_shared(); + shared_ptr wall = make_shared(); + shared_ptr route = make_shared(); public: - Cli(any widthI, any heightI, any wallI, any routeI); + Cli(any widthI, any heightI, any wallI, any routeI); - void print(vector> grid); + void print(vector> grid); }; #endif /* CLI_H */