Java Reference
In-Depth Information
certain numerical quantities (such as Ȓ3 toastersȓ), another describes a
fixed charge (such as Ȓshipping: $5.00ȓ). Hint: Use inheritance. Produce a
UML diagram of your modified implementation.
΢΢ Exercise P12.2. The invoice-printing program is somewhat unrealistic
because the formatting of the LineItem objects won't lead to good visual
results when the prices and quantities have varying numbers of digits.
Enhance the format method in two ways: Accept an int[] array of
column widths as a parameter. Use the NumberFormat class to format
the currency values.
΢΢ Exercise P12.3. The invoice-printing program has an unfortunate flawȌit
mixes Ȓbusiness logicȓ, the computation of total charges, and
Ȓpresentationȓ, the visual appearance of the invoice. To appreciate this
flaw, imagine the changes that would be necessary to draw the invoice in
HTML for presentation on the Web. Reimplement the program, using a
separate InvoiceFormatter class to format the invoice. That is, the
Invoice and LineItem methods are no longer responsible for
formatting. However, they will acquire other responsibilities, because the
InvoiceFormatter class needs to query them for the values that it
΢΢΢ Exercise P12.4. Write a program that teaches arithmetic to your younger
brother. The program tests addition and subtraction. In level 1 it tests
only addition of numbers less than 10 whose sum is less than 10. In level
2 it tests addition of arbitrary one-digit numbers. In level 3 it tests
subtraction of one-digit numbers with a non-negative difference.
Generate random problems and get the player input. The player gets up
to two tries per problem. Advance from one level to the next when the
player has achieved a score of five points.
΢΢΢ Exercise P12.5. Design a simple e-mail messaging system. A message
has a recipient, a sender, and a message text. A mailbox can store
messages. Supply a number of mailboxes for different users and a user
interface for users to log in, send messages to other users, read their own
messages, and log out. Follow the design process that was described in
this chapter.
Search WWH ::

Custom Search