Semaine 4, jour 5

This commit is contained in:
gauvainboiche
2026-01-16 17:13:01 +01:00
parent 54bb4d7628
commit 3f609ad139
38 changed files with 556 additions and 10 deletions

View File

@@ -0,0 +1,6 @@
from math import pi
class Point:
def __init__(self, x: float, y: float):
self.x = x
self.y = y

View File

@@ -1,10 +1,6 @@
# Composition: traduit une relation "A UN" "POSSED UN" "DEPEND DE"
from math import pi
class Point:
def __init__(self, x: float, y: float):
self.x = x
self.y = y
from composition import Point
class Forme: # Abstraction
def __init__(self, centre: Point):
@@ -16,14 +12,16 @@ class Forme: # Abstraction
def perimetre(self):
raise NotImplementedError("Attention perimetre doit etre redefini")
class Cercle(Forme):
class Cercle:
def __init__(self, centre: Point, rayon: float):
super().__init__(centre)
self.centre = centre
self.rayon = rayon
@property
def aire(self):
return pi * self.rayon ** 2
@property
def perimetre(self):
return 2 * pi * self.rayon