mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-03-14 05:06:55 +01:00
Corrected ex1, ready to push
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
class Plants:
|
||||
class Plant:
|
||||
name: str
|
||||
height: int
|
||||
days: int
|
||||
|
||||
def __init__(self, name, height, days):
|
||||
def __init__(self, name: str, height: int, days: int) -> None:
|
||||
"""Init plant with his value"""
|
||||
self.name = name
|
||||
self.height = height
|
||||
self.days = days
|
||||
|
||||
def print_plant(self):
|
||||
print(self.name.capitalize() + ":", self.height, end="")
|
||||
print("cm,", self.days, "days old")
|
||||
def print_plant(self) -> None:
|
||||
"""Display plant informations"""
|
||||
print(self.name, ": ", self.height,
|
||||
"cm, ", self.days, " days old", sep="")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
x = Plants("rose", 25, 30)
|
||||
y = Plants("sunflower", 80, 45)
|
||||
z = Plants("cactus", 15, 120)
|
||||
x = Plant("rose", 25, 30)
|
||||
y = Plant("sunflower", 80, 45)
|
||||
z = Plant("cactus", 15, 120)
|
||||
print("=== Garden Plant Registry ===")
|
||||
x.print_plant()
|
||||
y.print_plant()
|
||||
|
||||
Reference in New Issue
Block a user