Class Checkout

java.lang.Object
  |
  +--Checkout

public class Checkout
extends java.lang.Object

Maintains a list of DessertItem references There is no limit to the number of DessertItem's in the list


Constructor Summary
Checkout()
          Creates a Checkout instance with an empty list of DessertItem's
 
Method Summary
 void clear()
          Clears the Checkout to begin checking out a new set of items
 void enterItem(DessertItem item)
          A DessertItem is added to the end of the list of items
 int numberOfItems()
          Returns the number of DessertItem's in the list
 java.lang.String toString()
          Returns a String representing a receipt for the current list of items
 int totalCost()
          Returns total cost of items in cents (without tax)
 int totalTax()
          Returns total tax on items in cents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Checkout

public Checkout()
Creates a Checkout instance with an empty list of DessertItem's

Method Detail

numberOfItems

public int numberOfItems()
Returns the number of DessertItem's in the list

Returns:
number of DessertItem's in the list

enterItem

public void enterItem(DessertItem item)
A DessertItem is added to the end of the list of items

Parameters:
item - DessertItem to add to list of items

clear

public void clear()
Clears the Checkout to begin checking out a new set of items


totalCost

public int totalCost()
Returns total cost of items in cents (without tax)

Returns:
total cost of items in cents (without tax)

totalTax

public int totalTax()
Returns total tax on items in cents

Returns:
total tax on items in cents

toString

public java.lang.String toString()
Returns a String representing a receipt for the current list of items

Overrides:
toString in class java.lang.Object
Returns:
a String representing a receipt for the current list of DessertItem's with the name of the Dessert store, the items purchased, the tax, and the total cost, for example,
 
      M & M Dessert Shoppe
      --------------------
 
 Strawberry Ice Cream       1.45
 Caramel Sundae with
 Vanilla Ice Cream          1.55
 1.33 lbs. @ .89 /lb.
 Gummy Worms                1.18
 4 @ 3.99 /dz.
 Chocolate Chip Cookies     1.33
 1.50 lbs. @ 2.09 /lb.
 Salt Water Taffy           3.14
 3.00 lbs. @ 1.09 /lb.
 Candy Corn                 3.27
 
 Tax                         .77
 Total Cost                12.69