ICS H21 • UC IRVINE • DAVID G. KAY • FALL 2007

Lab Assignment 9

This assignment is due at the end of lab on Friday, November 30.

Choose a partner for this assignment, someone you haven't worked with already. Especially for this assignment, we recommend that you find somebody whose experience with Java is about the same as yours.

(a)

(h) Do exercises 35.2.2, 35.2.3, and 35.4.1.

Then do exercises 37.5.1, 37.5.2, and 37.5.3.

Submit your definitions via Checkmate.

Make sure that both partners know how to do the Java programming tasks from the Ninth Homework assignment.

(b) Download a completed version of the Java program from class on Tuesday; it's at http://www.ics.uci.edu/~kay/courses/h21/hw/Restaurants1.zip.

(b.1) Run and test the program to make sure it works for you, using a programming environment of your choice (e.g., the command-line, Eclipse, DrJava).

(b.2) Modify the program to give the user an additional menu choice:

e: Remove (erase) all the restaurants from the collection

When the user types 'e', the program should remove all the restaurants from the collection (so that, for example, if the next command were 'p', nothing would be printed).

This involves changing the menu and command handler; it also means adding an eraseAll method to the RestaurantList class.

(b.3) Add an averagePrice method to the RestaurantList class; it should return a double representing the average price at all the restaurants. Check out the description of the ArrayList class at java.sun.com to see if there's a way to get the size of an ArrayList. Then add a command to the menu so the user can see the average price.

(b.4) Modify the program so that it adds another menu item:

a: Adjust prices for the dishes served

When the user types 'a', the program should ask the user for an amount (positive or negative) representing a percentage change in price (so that 100 would double a price and -50 would cut it in half). Then it should apply that price change to the prices for all the restaurants in the collection.

This requires both an adjustPrice method in the Restaurant class and an adjustPrices method in the RestaurantList class (to apply it to every Restaurant in the collection).

Submit the files that comprise your modified program via Checkmate.

(c) Remember that each partner must complete a partner evaluation form via the Survey tool on eee.uci.edu.


Based in part on ICS H21assignments by David G. Kay from Fall 2003; modified by David G. Kay, Fall 2004.


David G. Kay, kay@uci.edu
Friday, November 14, 2008 2:11 PM