summaryrefslogtreecommitdiff
path: root/py01/ex1/ft_garden_data.py
blob: e5d84859973ecc94ffcd643f497053c4343bbb01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()