class Plant:
    def __init__(self, name, water, sun):
        self.name = name
        self.water = water
        self.sun = sun

    def watering(self, water: int = 1) -> None:
        self.water += water
        print(f"Watering {self.name} success")

    def check_plant_health(name, water, sun):
        srt = f"Error checking {name}: "
        if water < 1:
            raise ValueError(f"{srt}Water level {water} is too low (min 1)")
        if water > 10:
            raise ValueError(f"{srt}Water level {water} is too high (max 10)")

        if sun < 2:
            raise ValueError(f"{srt}Sunlight hours {sun} is too low (min 2)")
        if sun > 12:
            raise ValueError(f"{srt}Sunlight hours {sun} is too high (max 12)")

        return f"{name}: healthy (water: {water}, sun: {sun})"


class Garden:
    def __init__(self):
        self._plants: list[Plant] = []

    def add_plant(self, plant: Plant) -> None:
        if plant.name == "":
            raise ValueError("Error adding plant: Plant name cannot be empty!")
        else:
            self._plants.append(plant)
            print(f"Added {plant.name} succesfully")

    def water_plants(self) -> None:
        print("Open watering system")
        try:
            for p in self._plants:
                p.water += 1
                print(f"Watering {p.name}")
        except AttributeError:
            print(f"Error: Cannot water {p} - invalid plant!")
        finally:
            print("Closing watering system (cleanup)")

    def check_garden_health(self) -> None:
        print("\nChecking Plant health...")
        for p in self._plants:
            try:
                print(Plant.check_plant_health(p.name, p.water, p.sun))
            except ValueError as e:
                print(e)


garden = Garden()
print("=== Garden Management System ===\n")
print("Adding plants to garden...")
try:
    garden.add_plant(Plant("tomato", 5, 8))
    garden.add_plant(Plant("lettuce", 14, 3))
    garden.add_plant(Plant("", 5, 6))
except ValueError as e:
    print(e)
print("\nWatering plants...")
garden.water_plants()
garden.check_garden_health()
print("Garden management system test complete!")
