diff --git a/05_OO/MP/AnsiConsoleDemo.cpp b/05_OO/MP/AnsiConsoleDemo.cpp index 136daf0..f149f11 100644 --- a/05_OO/MP/AnsiConsoleDemo.cpp +++ b/05_OO/MP/AnsiConsoleDemo.cpp @@ -1,6 +1,6 @@ #include #include -#include "AnsiConsole.h" +#include "../../helpers/AnsiConsole.h" /* see diff --git a/05_OO/MP/shapes_main.cpp b/05_OO/MP/shapes_main.cpp index 33349b9..b514f01 100644 --- a/05_OO/MP/shapes_main.cpp +++ b/05_OO/MP/shapes_main.cpp @@ -6,7 +6,7 @@ struct Position { int x; int y; - Position(int x_ = 0, int y_ = 0) { + explicit Position(int x_ = 0, int y_ = 0) { x = x_; y = y_; } @@ -16,7 +16,7 @@ class Point { protected: Position _position; public: - Point(int x = 0, int y = 0); + explicit Point(int x = 0, int y = 0); void draw(); }; @@ -34,7 +34,7 @@ protected: Position _position; int _radius; public: - Circle(int x = 0, int y = 0, int radius = 0); + explicit Circle(int x = 0, int y = 0, int radius = 0); void draw(); }; @@ -55,10 +55,10 @@ void Circle::draw() { double x_relative = double(i) - double(x_start); double h = sqrt(x_relative * (x_stop - x_start - x_relative)); ansiConsole.printText(_position.x + int(x_relative) - _radius / 2, - _position.y + h, "#", + static_cast(_position.y + h), "#", Colors::GREEN); ansiConsole.printText(_position.x + int(x_relative) - _radius / 2, - _position.y - h, "#", + static_cast(_position.y - h), "#", Colors::GREEN); } @@ -71,7 +71,7 @@ protected: int height; public: - Rectangle(int x = 0, int y = 0, int width = 0, int height = 0); + explicit Rectangle(int x = 0, int y = 0, int width = 0, int height = 0); void draw(); }; @@ -103,20 +103,20 @@ int main(int argc, char **argv) { // x and y are more like column and row ansiConsole.printText(5, 5, "Hello, World!"); - Point *p = new Point(10, 10); + auto *p = new Point(10, 10); p->draw(); - Point *p2 = new Point(2, 10); + auto *p2 = new Point(2, 10); p2->draw(); - Circle *c = new Circle(30, 15, 10); + auto *c = new Circle(30, 15, 10); c->draw(); - Point *p3 = new Point(30, 15); + auto *p3 = new Point(30, 15); p3->draw(); - Rectangle *r = new Rectangle(20, 20, 20, 20); + auto *r = new Rectangle(20, 20, 20, 20); r->draw(); diff --git a/CMakeLists.txt b/CMakeLists.txt index d7ab7cb..1c1cfd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(04_UDEF_Testat 04_UDEF/Testat/Testat.cpp) add_executable(05_OO_MP 05_OO/MP/shapes_main.cpp helpers/AnsiConsole.cpp) add_executable(05_OO_Testat 05_OO/Testat/shapes_main.cpp helpers/AnsiConsole.cpp) +add_executable(05_OO_Demo 05_OO/MP/AnsiConsoleDemo.cpp helpers/AnsiConsole.cpp) add_executable(06_POLY_MP 06_POLY/MP/main_mp5_POLY.cpp) #add_executable(06_POLY_Testat 06_POLY/Testat/main_mp5_POLY.cpp)