Scenarios are a formal method of describing the sequence of events in a function that show the interaction of the function with other functions in the same or different classes.
Consider the problem of computing the cost of the grocery list in example 5, the process could be described as loop through the list and ask each item on the list for its cost. Add this cost to the total and return the total. Notice that this function asks each of the items in the list for its cost. If we had not listed a cost function as a member of GroceryItem, it would be clear here that we need such a function.
Scenarios formalize the process of cataloging functions called from a function. A scenario for our compute cost function is given below:
From this scenario it becomes clear that you must have a way to loop through the list of GroceryItems retrieve each item and find out if you are at the end of a list. This introduces the concept of iterator.