class Cookie:
def __init__(self, name, fix, duration):
self.name = name # Cookie name
self.fix = fix # What the cookie fixes
self.duration = duration #How long the fix lasts
def __repr__(self): #For easy printing/debugging
return f"Cookie(name='{self.name}', fix='{self.fix}', duration={self.duration})"
def create_cookie_structure():
"""Creates a nested structure of cookies."""
cookies = {
"headache": Cookie("Peppermint Patty", "Headache relief", 2),
"fatigue": Cookie("Chocolate Chunk", "Energy boost", 1),
"sadness": Cookie("Ginger Snap", "Mood lifting", 3),
"stress": Cookie("Lemon Crumb", "Calming effect", 1.5),
"low_energy": Cookie("Oatmeal Raisin", "Sustained energy", 2.5)
}
# Group cookies by category (optional - for more complex structures)
categories = {
"headache": cookies["headache"],
"energy": [cookies["fatigue"], cookies["low_energy"]],
"mood": [cookies["sadness"]],
"relaxation": [cookies["stress"]]
}
return categories #Return the dictionary of cookies
if __name__ == '__main__':
cookie_structure = create_cookie_structure()
print(cookie_structure) #Prints the entire structure
print(cookie_structure["headache"].fix) #Prints the fix for headaches
Add your comment