Semaine 4, jour 5
This commit is contained in:
6
Semaine_04/Fonctions/composition.py
Normal file
6
Semaine_04/Fonctions/composition.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from math import pi
|
||||
|
||||
class Point:
|
||||
def __init__(self, x: float, y: float):
|
||||
self.x = x
|
||||
self.y = y
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user