A stamp dispenser. For example, if the amount passed to add causes the balance to exceed the price of a stamp, a stamp is dispensed. Otherwise, the balance is increased. The object uses the current value of its balance variable to decide what to do when its add method is invoked. The StampDispenser also enables clients to be notified of important events by registering themselves via the addStampDispenserListener method.
Clients can change their minds via the removeStampDispenser method.
Stamp dispenser listener. The client that invoked the add method would be code that knows that money was inserted into the real slot. The client that invoked the returnCoins method would be code that knows the return coins lever was pressed. Stamp dispenser event. A StampDispenserEvent contains information the listener can use to respond to the event.