File size: 535 Bytes
275b9f3
 
 
 
 
 
 
 
 
 
 
 
 
 
b1ce64c
 
275b9f3
 
 
 
 
 
 
 
b1ce64c
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
25
26
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):
        """Calculate the area of the circle"""
        return 3.14 * (self.radius ** 2)

@dataclass
class Rectangle(Shape):
    """Rectangle shape"""
    width: float
    height: float

    def area(self):
        """Calculate the area of the rectangle"""
        return self.width * self.height