ckaraffa wrote:Why in the world would you write a separate routine for cooking the different contents AND pass the contents (i.e., cookbacon() and cooksausage())?
To make it clear to non-progammers what was going on... Object overloading is hardly understood by most programers... And second doing it this way, you'd still need to pass in the object you were cooking... You actually need bacon in order to cook bacon...
ckaraffa wrote:Wouldn't it be better practice to write a single cook routine and simply pass the meat by reference? That's what you did with identifying the contents of the fridge, after all.
Yes but as explained before easier for people to understand.
And where does the "cookeggs" routine get information on how to prepare the eggs?
The objects (eggs, bacon, sausage, ceral) all contain private functions which supply all the information needed on preparing them.
Furthermore, I see no exception handling should the fridge contain neither bacon nor sausage.
None is needed that is what the if statements are for...
There is no maketoast() routine.
I don't like toast
And there is no test to ensure that the bacon returned by cookbacon() is sufficiently crispy before continuing through to eatbreakfast().
In the cookbacon function there are checks for personal preference on desired crisp.
Finally, and most egregiously, your function precludes "breakfast any time", which makes your program useless to customers such as Denny's, IHOP, and diners everywhere.
This be no means restricts you from eating it at any time, this mearly ensures you are eating breakfast in the morning. As it is the most important meal of the day after all.