7  Lab Thursday am:

Methods for lists

(14.1.1, 14.1.2, 14.1.3), (optional 14.1.4)

Develop the data definition for a list of grocery items selected among those described in  6.
  1. Develop the method total that computes the total price of the purchase.

  2. Develop the method brandlist that produces a list of all items with the specified brand name.

  3. Develop the method highestPrice that determines the highest unit price among all items in the shopping list.  Solution

Develop the data definition for a shopping list of grocery items selected among those described in  6. This time, the list also records how many of each item do we need.
  1. Develop the data definition for this class hierarchy.

  2. Develop the method total that computes the total price of the purchase.

  3. Develop the method saletotal that computes the total price of the purchase when all items with the specified brand name are on sale at 20% off.  Solution

Develop a program that assists a bookstore manager in a discount bookstore (see exercise 6.
  1. Develop the class hierarchy to represent a list of books in the discount bookstore.

  2. Describe in English examples of three book lists and represent them as objects in this class hierarchy.

  3. develop the method price that computes the total for the sale, based on the sale price of each book.

  4. Develop the method thisAuthor that produces a list of all books by this author in the bookstore list.  Solution

Develop the following additional methods for the river system.
  1. Develop the method maxlength that computes the length of the longest river segment.

  2. Develop the method confluences that counts the number of confluences in the river system.

  3. Develop the method locations that produces a list of all locations on this river - the sources, the mouths, and the confluences.  Solution

Methods for trees and similar structures