42NEXT_subject_en/done_exo/codecultivation/ex4/ft_garden_security.py

35 lines
845 B
Python

class Plant:
def __init__(self, name, height, age):
self.name = name
self.height = height
self.age = age
rose = Plant("Rose", 10, 15)
def get_height(self):
print("Invalid operation attempted: ")
print(f"height {self.height}cm [REJECTED]")
print("Security: Negative height rejected\n")
def get_age(self):
print(f"Invalid operation attempted: {self.age} days [REJECTED]")
print("Security: Negative age rejected")
def ft_garden_security():
print("=== Garden Security System ===")
if rose.height < 0:
get_height(rose)
if rose.age < 0:
get_age(rose)
if rose.age >= 0 & rose.height >= 0:
print(f"Plant created: {rose.name}")
print(f"Height updated: {rose.height}cm [OK]")
print(f"Age updated: {rose.age} days [OK]")
ft_garden_security()