summaryrefslogtreecommitdiff
path: root/_legacy/oop/oop.py
diff options
context:
space:
mode:
authorZhongheng Liu <z.liu@outlook.com.gr>2025-02-19 09:43:52 +0200
committerZhongheng Liu <z.liu@outlook.com.gr>2025-02-19 09:43:52 +0200
commit8834da60a01294fd509c7cebf3b129fcc378d152 (patch)
treea1c6c4bd71e95780f87d35240754c5b54d3042ae /_legacy/oop/oop.py
parent34bd7099d27656b4454015b0c410ca1713db5271 (diff)
downloadcs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.gz
cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.bz2
cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.zip
chore: changing to ipynb
Diffstat (limited to '_legacy/oop/oop.py')
-rw-r--r--_legacy/oop/oop.py32
1 files changed, 32 insertions, 0 deletions
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