добавил

This commit is contained in:
vitalii Malcov 2023-09-12 07:46:05 +02:00
parent e794f1333e
commit 37bccaf0b8
9 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1 @@
"{'shapes': [{\"width\": 5, \"height\": 10, \"color\": \"red\", \"type\": \"Rectangle\"}, {\"radius\": 7, \"color\": \"blue\", \"type\": \"Circle\"}, {\"side\": 4, \"color\": \"green\", \"type\": \"Square\"}]}"