2024-03-22 22:14:05 +01:00
|
|
|
import random
|
|
|
|
|
2024-03-07 18:01:12 +01:00
|
|
|
|
|
|
|
class Plant:
|
2024-03-22 22:14:05 +01:00
|
|
|
def __init__(self, name, plant_type, water_requirements, nutrients_requirements, growth_level):
|
|
|
|
self.name = name
|
|
|
|
self.plant_type = plant_type
|
|
|
|
self.water_requirements = water_requirements
|
|
|
|
self.nutrients_requirements = nutrients_requirements
|
|
|
|
self.growth_level = growth_level
|
|
|
|
|
|
|
|
def try_to_grow(self, water, nutrients):
|
|
|
|
if (water >= self.water_requirements) and (nutrients >= self.nutrients_requirements):
|
|
|
|
i = random.randint(5, 12)
|
|
|
|
if self.growth_level+i > 100:
|
2024-03-24 16:12:50 +01:00
|
|
|
i = 100 - self.growth_level
|
2024-03-22 22:14:05 +01:00
|
|
|
self.growth_level += i
|
2024-03-25 01:02:03 +01:00
|
|
|
print("The plant is growing")
|
|
|
|
else:
|
|
|
|
print("Unable to grow due to bad condition of the ground")
|
2024-03-22 22:14:05 +01:00
|
|
|
|
2024-05-27 00:32:20 +02:00
|
|
|
def update_name(self, predicted_class):
|
|
|
|
if predicted_class == "Apple":
|
2024-05-27 05:28:48 +02:00
|
|
|
self.name = "apple"
|
|
|
|
self.plant_type = 'fruit'
|
2024-03-07 18:01:12 +01:00
|
|
|
|
2024-05-27 04:32:31 +02:00
|
|
|
elif predicted_class == "Radish":
|
2024-05-27 05:28:48 +02:00
|
|
|
self.name = "radish"
|
|
|
|
self.plant_type = 'vegetable'
|
2024-05-27 00:32:20 +02:00
|
|
|
|
|
|
|
elif predicted_class == "Cauliflower":
|
2024-05-27 05:28:48 +02:00
|
|
|
self.name = "cauliflower"
|
|
|
|
self.plant_type = 'vegetable'
|
2024-05-27 04:32:31 +02:00
|
|
|
|
2024-05-27 00:32:20 +02:00
|
|
|
elif predicted_class == "Wheat":
|
2024-05-27 05:28:48 +02:00
|
|
|
self.name = "wheat"
|
|
|
|
self.plant_type = 'cereal'
|