01: /**
02:    A simple invoice formatter.
03: */
04: public class SimpleFormatter implements InvoiceFormatter
05: {
06:    public String formatHeader()
07:    {
08:       total = 0;
09:       return "     I N V O I C E\n\n\n";
10:    }
11: 
12:    public String formatLineItem(LineItem item)
13:    {
14:       total += item.getPrice();
15:       return (String.format(
16:             "%s: $%.2f\n",item.toString(),item.getPrice()));
17:    }
18: 
19:    public String formatFooter()
20:    {
21:       return (String.format("\n\nTOTAL DUE: $%.2f\n", total));
22:    }
23: 
24:    private double total;
25: }