01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package horstmann.ch05_invoice;
/**
   A simple invoice formatter.
 */
public class SimpleFormatter implements InvoiceFormatter
{
  public String formatHeader()
  {
    total = 0;
    return "     I N V O I C E\n\n\n";
  }

  public String formatLineItem(LineItem item)
  {
    total += item.getPrice();
    return (String.format(
        "%s: $%.2f\n",item.toString(),item.getPrice()));
  }

  public String formatFooter()
  {
    return (String.format("\n\nTOTAL DUE: $%.2f\n", total));
  }

  private double total;
}