001package horstmann.ch05_invoice;
002/**
003   A simple invoice formatter.
004 */
005public class SimpleFormatter implements InvoiceFormatter
006{
007        public String formatHeader()
008        {
009                total = 0;
010                return "     I N V O I C E\n\n\n";
011        }
012
013        public String formatLineItem(LineItem item)
014        {
015                total += item.getPrice();
016                return (String.format(
017                                "%s: $%.2f\n",item.toString(),item.getPrice()));
018        }
019
020        public String formatFooter()
021        {
022                return (String.format("\n\nTOTAL DUE: $%.2f\n", total));
023        }
024
025        private double total;
026}