File size: 436 Bytes
275b9f3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from dataclasses import dataclass
@dataclass
class Shape:
"""Base class for shapes"""
def area(self):
raise NotImplementedError
@dataclass
class Circle(Shape):
"""Circle shape"""
radius: float
def area(self):
return 3.14 * self.radius ** 2
@dataclass
class Rectangle(Shape):
"""Rectangle shape"""
width: float
height: float
def area(self):
return self.width * self.height |