2023-08-27 14:12:28 +02:00
|
|
|
from abc import abstractmethod
|
|
|
|
from abc import ABC
|
|
|
|
|
|
|
|
|
|
|
|
class Shape(ABC):
|
|
|
|
color = ''
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def area(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def perimetr(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def create_shape(json):
|
|
|
|
if "type" in json:
|
|
|
|
shape_type = json["type"]
|
|
|
|
if shape_type == "circle":
|
2023-08-28 08:00:52 +02:00
|
|
|
return json["radius"]
|
2023-08-27 14:12:28 +02:00
|
|
|
elif shape_type == "square":
|
2023-08-28 08:00:52 +02:00
|
|
|
return json["side"]
|
2023-08-27 14:12:28 +02:00
|
|
|
elif shape_type == "rectangle":
|
2023-08-28 08:00:52 +02:00
|
|
|
return json["width"], json["height"]
|
2023-08-27 14:12:28 +02:00
|
|
|
else:
|
|
|
|
raise TypeError(f'Неизвестная фигура {shape_type}')
|
2023-08-28 08:00:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print()
|