From 508af05677c285ad8f4c2b65bf938bf2372b720c Mon Sep 17 00:00:00 2001 From: Arkadiusz Hypki Date: Tue, 4 Apr 2023 15:42:52 +0200 Subject: [PATCH] Added Python files from our 1st classes --- python/Circle.py | 11 +++++++++++ python/Figure.py | 4 ++++ python/Rectangle.py | 13 +++++++++++++ python/Square.py | 12 ++++++++++++ python/main.py | 15 +++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 python/Circle.py create mode 100644 python/Figure.py create mode 100644 python/Rectangle.py create mode 100644 python/Square.py create mode 100644 python/main.py diff --git a/python/Circle.py b/python/Circle.py new file mode 100644 index 0000000..de3c245 --- /dev/null +++ b/python/Circle.py @@ -0,0 +1,11 @@ +from Figure import Figure + + +class Circle(Figure): + _r = None + + def setr(self, r): + self._r = r + + def area(self): + print("area = " + str(3.14 * self._r**2)) diff --git a/python/Figure.py b/python/Figure.py new file mode 100644 index 0000000..009309f --- /dev/null +++ b/python/Figure.py @@ -0,0 +1,4 @@ +class Figure: + + def area(self): + print("Not implemented") \ No newline at end of file diff --git a/python/Rectangle.py b/python/Rectangle.py new file mode 100644 index 0000000..7815e5f --- /dev/null +++ b/python/Rectangle.py @@ -0,0 +1,13 @@ +from Figure import Figure +from Square import Square + + +class Rectangle(Square): + + _y = None + + def sety(self, y): + self._y = y + + def area(self): + print("area = " + str(self._x * self._y)) diff --git a/python/Square.py b/python/Square.py new file mode 100644 index 0000000..e4564b3 --- /dev/null +++ b/python/Square.py @@ -0,0 +1,12 @@ +from Figure import Figure + + +class Square(Figure): + + _x = None + + def setx(self, x): + self._x = x + + def area(self): + print("area = " + str(self._x * self._x)) diff --git a/python/main.py b/python/main.py new file mode 100644 index 0000000..14698d6 --- /dev/null +++ b/python/main.py @@ -0,0 +1,15 @@ +from Circle import Circle +from Figure import Figure +from Rectangle import Rectangle + +if __name__ == '__main__': + r = Rectangle() + r.setx(4) + r.sety(8) + r.area() + + c = Circle() + c.setr(1) + c.area() + + print('Finished')