# Composition: traduit une relation "A UN" "POSSED UN" "DEPEND DE"
from math import pi
from composition import Point

class Forme: # Abstraction
    def __init__(self, centre: Point):
        self.centre = centre

    def aire(self):
        raise NotImplementedError("Attention aire doit etre redefini")

    def perimetre(self):
        raise NotImplementedError("Attention perimetre doit etre redefini") 

class Cercle:
    def __init__(self, centre: Point, rayon: float):
        self.centre = centre
        self.rayon = rayon
    
    @property
    def aire(self):
        return pi * self.rayon ** 2
    
    @property
    def perimetre(self):
        return 2 * pi * self.rayon

class Rectangle(Forme):
    def __init__(self, centre: Point, longeur: float, largeur: float):
        super().__init__(centre)
        self.longueur = longeur
        self.largeur = largeur

    def aire(self):
        return self.longueur * self.largeur
    
    def perimetre(self):
        return 2 * (self.longueur + self.largeur)

cercle1 = Cercle(centre= Point(2, 2), rayon= 5)
cercle2 = Cercle(centre= Point(-2, 2), rayon= 6)
rect1 = Rectangle(centre= Point(0, 0), longeur= 12, largeur= 5)
rect2 = Rectangle(centre= Point(1, 1), longeur= 10, largeur= 6)

formes = [cercle1, cercle2, rect1, rect2]
for forme in formes:
    print(forme.aire())