добавил
This commit is contained in:
parent
e794f1333e
commit
37bccaf0b8
|
@ -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
|
||||
|
|
@ -0,0 +1 @@
|
|||
"{'shapes': [{\"width\": 5, \"height\": 10, \"color\": \"red\", \"type\": \"Rectangle\"}, {\"radius\": 7, \"color\": \"blue\", \"type\": \"Circle\"}, {\"side\": 4, \"color\": \"green\", \"type\": \"Square\"}]}"
|
Loading…
Reference in New Issue