M.6. Class DepositSlot

Class DepositSlot (Fig. M.5) represents the deposit slot of the ATM. Like the version of class CashDispenser presented here, this version of class DepositSlot merely simulates the functionality of a real hardware deposit slot. DepositSlot has no attributes and only one method—isEnvelopeReceived (lines 8–11)—that indicates whether a deposit envelope was received.

Figure M.5. Class DepositSlot represents the ATM’s deposit slot.
 1  // DepositSlot.java
 2  // Represents the deposit slot of the ATM
 3
 4  public class DepositSlot
 5  {
 6     // indicates whether envelope was received (always returns true,
 7     // because this is only a software simulation of a real deposit slot)
 8     public boolean isEnvelopeReceived()
 9     {
10        return true;

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.