MORE FOOD Modifications and clarifications of the FOOD Visitor Pattern Assignment I've decided to add an additional component to the Food Assignment and make it due right before the thanksgiving break. 1. Please reload the food assignment description for latest changes. Here is a summary of what you need to do for the basic parts of the assignment: a. Write a visitor class that adds up the calories for a list of fooditems. This class can just work with the exiting visitee classes (fruit, vegetable, meat, nofood). b. Add another visitee class, that is, a new kind of food such as "candy" or "beverage". The class should have some property that distinguishes it from the other visitee classes. The Visitor Pattern makes it easy to add a new visitor, but it'll be harder to add a new visitee class in a modular manner (without editing the existing program). UNDERGRADUATES may just edit the exisiting fooditem and foodvisitor interfaces, which also means you'll have to modify the all visitor classes accordingly. GRADUATE students are required to use the mechanisms I demonstrated with the "student visitors" program. That is, use a separate interface and (possibly) an object adapter class. Undergrads are also strongly encouraged to try this method, which is really the better approach anyway. c. Write a visitor class, one that can also visit your new visitee, that prints the food item information in a list in XML format. I showed you how to write to a file in the assignment statement. You should flush and close the file stream when you reach a "no food" object. Your output needs to be well-formatted. d. Write a visitor class, one that does not have to visit your new visitee, that determines if a food list is ordered. That is, if all fruits are before vegetables and all vegetables are before meats. Use the attached finite automaton diagram for a hint as to how to do this. As you do this assignment you may encounter situations where you will have to change "private" class elements to "protected" or "internal". You can decide from your own experience whether calling something "private" is logical or simply naive. ---------------------- ADDENDUM -------------------------- Here's the addition to the assignment: Make your visitor pattern parametrically typed using .Net Generics. That is, the return type of visit methods (and the accept method) should be changed from "object" to a type variable. Make sure you understand what the potential advantages of this approach are. See the program "exptree5.cs" (Parametrized VP version of the expression tree program) if you're stuck. Remember that it is possible to parameterize an interface, a class, or just a single function within a class. You'll probably need the latter form.