Удаляю лишние файлы с классами
This commit is contained in:
parent
74e980176d
commit
bc920dd5b8
|
@ -1,13 +0,0 @@
|
|||
import math
|
||||
from shape import Shape
|
||||
|
||||
|
||||
class Circle(Shape):
|
||||
def __init__(self, radius):
|
||||
self.radius = radius
|
||||
|
||||
def area(self):
|
||||
return math.pi * (self.radius ** 2)
|
||||
|
||||
def perimetr(self):
|
||||
return 2 * math.pi * self.radius
|
|
@ -1,17 +0,0 @@
|
|||
from shape import Shape
|
||||
|
||||
|
||||
class Rectangle(Shape):
|
||||
def __init__(self, width, height):
|
||||
self.width = width
|
||||
self.height = height
|
||||
|
||||
def area(self):
|
||||
return self.width * self.height
|
||||
|
||||
def perimetr(self):
|
||||
return (self.width + self.height) * 2
|
||||
|
||||
|
||||
r1 = Rectangle(10, 20)
|
||||
print(r1.area())
|
|
@ -1,31 +0,0 @@
|
|||
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":
|
||||
return json["radius"]
|
||||
elif shape_type == "square":
|
||||
return json["side"]
|
||||
elif shape_type == "rectangle":
|
||||
return json["width"], json["height"]
|
||||
else:
|
||||
raise TypeError(f'Неизвестная фигура {shape_type}')
|
||||
|
||||
|
||||
|
||||
print()
|
|
@ -1,12 +0,0 @@
|
|||
from shape import Shape
|
||||
|
||||
|
||||
class Square(Shape):
|
||||
def __init__(self, side):
|
||||
self.side = side
|
||||
|
||||
def area(self):
|
||||
return self.side ** 2
|
||||
|
||||
def perimetr(self):
|
||||
return 4 * self.side
|
Loading…
Reference in New Issue