From 8834da60a01294fd509c7cebf3b129fcc378d152 Mon Sep 17 00:00:00 2001 From: Zhongheng Liu Date: Wed, 19 Feb 2025 09:43:52 +0200 Subject: chore: changing to ipynb --- _legacy/oop/oop.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 _legacy/oop/oop.py (limited to '_legacy/oop/oop.py') diff --git a/_legacy/oop/oop.py b/_legacy/oop/oop.py new file mode 100644 index 0000000..65c79f0 --- /dev/null +++ b/_legacy/oop/oop.py @@ -0,0 +1,32 @@ +import math +class shape: + def __init__(self): + pass + def area(self): + pass +class circle(shape): + def __init__(self, r): + shape.__init__(self) + self._radius = r + def area(self): + return self._radius * self._radius * math.pi +class rectangle(shape): + def __init__(self, side1, side2): + shape.__init__(self) + self._a = side1 + self._b = side2 + def area(self): + return self._a * self._b +class square(shape): + def __init__(self, side): + shape.__init__(self) + self._side = side + def area(self): + return self._side ** 2 + +sq = square(4) +cir = circle(7) +rect = rectangle(3,6) +print(sq.area()) +print(cir.area()) +print(rect.area()) \ No newline at end of file -- cgit