Assignment 2 ©2011 Felleisen, Proulx, Chadwick, et. al.
Due: 1/25/2011 @ 10:00pm
Work out as the following exercises from the textbook. Do not add them to your assignment submission, though you should keep them in your electronic portfolio in a separate directory of your pair’s repository, e.g., Portfolio-02.
Problem 2.4 on page 17
Problem 3.1 on page 25
Problem 4.4 on page 33
Problem 5.3 on page 44
Problem 5.9 on page 51
Problem 10.2 on page 97
Problem 10.5 on page 105
Problem 14.1 on page 140
Problem 14.7 on page 144
These problems should be checked into your pair’s SVN repository under the directory named Assignment-02 by the due date. See the individual problems for file naming requirements.
Answers to this problem should be placed in a Java file named Cities.java, in the Assignment-02/src directory of your pair’s Trac/SVN repository. Name your examples class CityExamples.
Convert your data representation for US cities from the previous assignment into data definitions in the FunJava language. (i.e., create a class City)
Make sure you have a separate class Loc for the location coordinates in latitude and longitude
Define a class hierarchy that represents a list of cities. Follow the DESIGN RECIPE FOR DATA DEFINITIONS. Remember to make examples of data in a CityExamples class.
Answers to this problem should be placed in a Java file named Lunches.java, in the Assignment-02/src directory of your pair’s Trac/SVN repository. Make sure the examples class is named different than the problem above (e.g., LunchExamples).
Design the classes (i.e., a class hierarchy) to represent lunch orders. For lunch a customer can choose a soup (soups have different flavors), a salad (one of several kinds, as well as a choice of several choices of dressings), and a sandwich. For a sandwich the customer selects the bread, the filling, and a list of extras (tomatoe, onion, mayo, mustard, olives, etc.). For each of the lunch parts we need to know whether or not they are vegetarian.
The restaurant charges individually for each selection, but all breads cost the same and each of the extras costs the same. There is no extra charge for dressing on the salad.
Make examples of at least two of each: soup, salad, dressings, breads, fillings, extras.
Make at least four examples of lunches where at least one of them must be vegetarian.
The class that represents the entire lunch order should be named Lunch. You can name all the other classes as you wish, but make sure your names are sensible and that your class names start with a capital letter.