(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.
Develop the method total
that computes the total price
of the purchase.
Develop the method brandlist
that produces a list of all
items with the specified brand name.
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.
Develop the data definition for this class hierarchy.
Develop the method total
that computes the total price
of the purchase.
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.
Develop the class hierarchy to represent a list of books in the discount bookstore.
Describe in English examples of three book lists and represent them as objects in this class hierarchy.
develop the method price
that computes the total for the
sale, based on the sale price of each book.
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.
Develop the method maxlength
that computes the length of the
longest river segment.
Develop the method confluences
that counts the number of
confluences in the river system.
Develop the method locations
that produces a list of all
locations on this river - the sources, the mouths, and the confluences.
Solution