Question: The protocol class is only giving me the protocols I need to implement in concrete classes in another file (dessert.py). The freezer class contains methods
- The protocol class is only giving me the protocols I need to implement in concrete classes in another file (dessert.py). The freezer class contains methods that if the put() method gets called then it also calls the chill(). The take() calls the thaw().
- In my second file (dessert.py), where my concrete classes are, the goal is to call the features of the protocol: chill(), thaw(), and temperature(). The method temperature() should be default be 'thaw' but if put() gets called on an instance of Cookie, then the temperature should now return to 'chilling', and if take() gets called on the same instance, then temperature() should now return 'thawing'.
- The instantiation of the Cookie class, the Freezer class, and calling the method for temperature() and put() are coded in a third file called dessertshop.py
- The goal is to create "my_cookie" and the temperature should by default be 'thawing' but once I call freezer.put(my_cookie) the print statements for temperature() should change to 'chilling'.
- I believe my temperature() method in dessert.py is incorrect. Can you help me understand how I can make temperature() change its return every time either put() or take() are implemented on an instance of a dessert?
dessertshop.py freezer = freeze.Freezer() my_cookie = dessert.Cookie("oatmeal raisin", 4, 3.45) print( f"Before putting item in the freezer, item is {my_cookie.temperature ()}") freezer.put(my_cookie) print(my_cookie.temperature())
Step by Step Solution
3.55 Rating (155 Votes )
There are 3 Steps involved in it
Solution To make the temperature method in dessertpy change its return every time either put or take are implemented on an instance of a dessert you c... View full answer
Get step-by-step solutions from verified subject matter experts
