Oct-17-2022, 05:46 AM
(This post was last modified: Oct-17-2022, 05:46 AM by deanhystad.)
The way you compute sufficient_reserves is wrong. Work through the logic for an order where you don't have enough coffee, but all the other reserves are sufficient. What is the value of sufficient_reserves.
You should also rethink how you are checking the reserves. How would you modify your program to allow making smoothies? Now you have fruit used in some recipes and not in others. Can you make your reserve_check more generic so it only checks items that are in the recipe?
This kind of code is very difficult to exapand. Imagine that you made enough money from the coffee shop to open a restaurant where you have hundreds of ingredients. What would this code look like:
You should also rethink how you are checking the reserves. How would you modify your program to allow making smoothies? Now you have fruit used in some recipes and not in others. Can you make your reserve_check more generic so it only checks items that are in the recipe?
This kind of code is very difficult to exapand. Imagine that you made enough money from the coffee shop to open a restaurant where you have hundreds of ingredients. What would this code look like:
if water_reserve - chosen_order_water <= 0: print("There isn't enough water. Please refill.") if milk_reserve - chosen_order_milk <= 0: print("There isn't enough milk. Please refill.") if coffee_reserve - chosen_order_coffee <= 0: print("There isn't enough coffee. Please refill.") else: sufficient_reserves = TrueYou can replace these lines of code with a loop and one comparison. The same code will work for 3 ingredients or a thousand.