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