()
| 9 | private Formatter f = |
| 10 | new Formatter(new StringBuilder()); |
| 11 | public ReceiptBuilder() { |
| 12 | f.format( |
| 13 | "%-15s %5s %10s%n", "Item", "Qty", "Price"); |
| 14 | f.format( |
| 15 | "%-15s %5s %10s%n", "----", "---", "-----"); |
| 16 | } |
| 17 | public void add(String name, int qty, double price) { |
| 18 | f.format("%-15.15s %5d %10.2f%n", name, qty, price); |
| 19 | total += price * qty; |