From 37bccaf0b8732b99a1e3ec1b001f6fd5d0493a5d Mon Sep 17 00:00:00 2001 From: vitalii Malcov Date: Tue, 12 Sep 2023 07:46:05 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HNS/{ => Excercises}/27.08.2023/Circle.py | 0 HNS/{ => Excercises}/27.08.2023/Rectangle.py | 0 HNS/Excercises/27.08.2023/Shape.py | 23 +++++++++++++++++++ HNS/Excercises/27.08.2023/Shapes zwei.json | 1 + .../27.08.2023/Shapes zwei.json.json | 0 HNS/{ => Excercises}/27.08.2023/Square.py | 0 HNS/{ => Excercises}/27.08.2023/classes.py | 0 HNS/{ => Excercises}/27.08.2023/main.py | 0 HNS/{ => Excercises}/27.08.2023/shapes.json | 0 9 files changed, 24 insertions(+) rename HNS/{ => Excercises}/27.08.2023/Circle.py (100%) rename HNS/{ => Excercises}/27.08.2023/Rectangle.py (100%) create mode 100644 HNS/Excercises/27.08.2023/Shape.py create mode 100644 HNS/Excercises/27.08.2023/Shapes zwei.json create mode 100644 HNS/Excercises/27.08.2023/Shapes zwei.json.json rename HNS/{ => Excercises}/27.08.2023/Square.py (100%) rename HNS/{ => Excercises}/27.08.2023/classes.py (100%) rename HNS/{ => Excercises}/27.08.2023/main.py (100%) rename HNS/{ => Excercises}/27.08.2023/shapes.json (100%) diff --git a/HNS/27.08.2023/Circle.py b/HNS/Excercises/27.08.2023/Circle.py similarity index 100% rename from HNS/27.08.2023/Circle.py rename to HNS/Excercises/27.08.2023/Circle.py diff --git a/HNS/27.08.2023/Rectangle.py b/HNS/Excercises/27.08.2023/Rectangle.py similarity index 100% rename from HNS/27.08.2023/Rectangle.py rename to HNS/Excercises/27.08.2023/Rectangle.py diff --git a/HNS/Excercises/27.08.2023/Shape.py b/HNS/Excercises/27.08.2023/Shape.py new file mode 100644 index 0000000..8990f48 --- /dev/null +++ b/HNS/Excercises/27.08.2023/Shape.py @@ -0,0 +1,23 @@ +import math +from abc import abstractmethod + + +class Shape: + color = '' + + @abstractmethod + def area(self): + pass + + @abstractmethod + def perimeter(self): + pass + + @staticmethod + def convert_to_json(obj): + if isinstance(obj, Shape): + result = obj.__dict__ + result['type'] = obj.__class__.__name__ + result['color'] = obj.color + return result + diff --git a/HNS/Excercises/27.08.2023/Shapes zwei.json b/HNS/Excercises/27.08.2023/Shapes zwei.json new file mode 100644 index 0000000..92be808 --- /dev/null +++ b/HNS/Excercises/27.08.2023/Shapes zwei.json @@ -0,0 +1 @@ +"{'shapes': [{\"width\": 5, \"height\": 10, \"color\": \"red\", \"type\": \"Rectangle\"}, {\"radius\": 7, \"color\": \"blue\", \"type\": \"Circle\"}, {\"side\": 4, \"color\": \"green\", \"type\": \"Square\"}]}" \ No newline at end of file diff --git a/HNS/Excercises/27.08.2023/Shapes zwei.json.json b/HNS/Excercises/27.08.2023/Shapes zwei.json.json new file mode 100644 index 0000000..e69de29 diff --git a/HNS/27.08.2023/Square.py b/HNS/Excercises/27.08.2023/Square.py similarity index 100% rename from HNS/27.08.2023/Square.py rename to HNS/Excercises/27.08.2023/Square.py diff --git a/HNS/27.08.2023/classes.py b/HNS/Excercises/27.08.2023/classes.py similarity index 100% rename from HNS/27.08.2023/classes.py rename to HNS/Excercises/27.08.2023/classes.py diff --git a/HNS/27.08.2023/main.py b/HNS/Excercises/27.08.2023/main.py similarity index 100% rename from HNS/27.08.2023/main.py rename to HNS/Excercises/27.08.2023/main.py diff --git a/HNS/27.08.2023/shapes.json b/HNS/Excercises/27.08.2023/shapes.json similarity index 100% rename from HNS/27.08.2023/shapes.json rename to HNS/Excercises/27.08.2023/shapes.json