class Fruit: """ A simple representation of a fruit Attributes ---------- name : (str) the name of the fruit color: (str) the color of the fruit eaten: (bool) whether the fruit has been eaten age: (int) how many days old the fruit is Methods ------- is_eaten(): (bool) returns whether the fruit has been eaten eat(): (None) "eats" the fruit allergy_check(allergic_color): (bool) checks whether the allergic_color matches the color of the fruit age_fruit(): (None) ages the fruit by one day """ def __init__(self, name, color): self.name = name self.color = color self.eaten = False self.age = 0 def is_eaten(self): """ returns whether the fruit has been eaten :return: (bool) whether the fruit has been eaten """ return self.eaten def eat(self): """ "eats" the fruit :return: (None) """ self.eaten = True def allergy_check(self, allergic_color): """ checks whether the allergic_color matches the color of the fruit :param allergic_color: (str) the allergic color to compare the color of the fruit to :return: """ return self.color == allergic_color def age_fruit(self): """ ages the fruit by one day :return: (None) """ self.age += 1 def __str__(self): return self.color + " " + self.name + " that is " + \ str(self.age) + " days old" def main(): fruit = Fruit("banana", "yellow") print(fruit) print(fruit.allergy_check("red")) fruit.age_fruit() print(fruit) print(fruit.is_eaten()) fruit.eat() print(fruit.is_eaten()) if __name__ == "__main__": main()