summaryrefslogtreecommitdiff
path: root/py01/ex1/ft_garden_data.py
diff options
context:
space:
mode:
authoryctct <yctct@yctct.com>2026-06-07 08:59:04 +0200
committeryctct <yctct@yctct.com>2026-06-07 08:59:04 +0200
commit15115b4c52bfda0d1cca9fa1155beecbb873ec35 (patch)
treeb3f0975e63eb04dcba732a78ce9bd9abda8acf01 /py01/ex1/ft_garden_data.py
First commit, add all files
Diffstat (limited to 'py01/ex1/ft_garden_data.py')
-rwxr-xr-xpy01/ex1/ft_garden_data.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/py01/ex1/ft_garden_data.py b/py01/ex1/ft_garden_data.py
new file mode 100755
index 0000000..e5d8485
--- /dev/null
+++ b/py01/ex1/ft_garden_data.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+
+
+# Create a class
+class Plant:
+ def __init__(self: 'Plant', name: str, height: float, age: int) -> None:
+ self.name = name
+ self.height = height
+ self.age = age
+
+# Method to grow the age
+ def grow_age(self: 'Plant') -> None:
+ self.age += 1
+
+# Method to grow the height
+ def grow_height(self: 'Plant') -> None:
+ self.height *= 1.04
+
+# Method to show the plant information
+ def show(self: 'Plant') -> None:
+ print(self.name + ": " + str(round(self.height, 1)) + "cm, "
+ + str(self.age) + " days old")
+
+
+print("=== Garden Plant Registry ===")
+
+
+def ft_garden_data() -> None:
+ Params = [("Rose", 25, 30), ("Sunflower", 80, 45), ("Cactus", 15, 120)]
+ for param in Params:
+ Plant(*param).show()
+
+
+if __name__ == "__main__":
+ ft_garden_data()