//ATM Simulation Interface - ATM components

ATM Simulation Interface - ATM components


/*
 * Example ATM simulation - file atmparts.h
 *
 * This file declares the classes that manage the ATM's components
 *
 * Copyright (c) 1996, 1997 - Russell C. Bjork
 *
 */

//

Interface for class CardReader

class CardReader
  {
    /* 
     * PURPOSE: Model the ATM component that reads a customer's card
     */

    public:

        CardReader();

        void ejectCard();
        void retainCard();

        enum ReaderStatus 
          { NO_CARD, UNREADABLE_CARD, CARD_HAS_BEEN_READ };

        ReaderStatus checkForCardInserted();
        int cardNumber() const;

    private:

        ReaderStatus    _status;
        int             _cardNumberRead;        
  };

//

Interface for class Display

class Display
  {
    /* 
     * PURPOSE: Model the ATM component that displays messages for the customer
     */

    public:

        Display();

        // The following display screens calling for the customer to take a
        // specific action
     
        void requestCard();
        void requestPIN();
        void displayMenu(const char * whatToChoose,
                         int numItems,
                         const char * items[]);
        void requestAmountEntry();
        void requestDepositEnvelope();
     
        // The following displays a screen reporting the customer's card
        // is unreadable
     
        void reportCardUnreadable();
    
        // The following displays a screen reporting why a transaction
        // failed, and asking if customer wants another.
      
        void reportTransactionFailure(const char * explanation);

        // The following are used in case the customer's PIN was incorrect
     
        void requestReEnterPIN();
        void reportCardRetained();

       // The following is used by the Keyboard to echo input as typed

       void echoInput(const char * echo);

       // Clear off the screen after a display has been seen

        void clearDisplay();
  };

//

Interface for class Keyboard

class Keyboard
  {
    /* 
     * PURPOSE: Model the ATM component that accepts input from the customer
     */

    public:

        Keyboard();

        int readPIN(Display & echoOn);
        int readMenuChoice(int numItems);
        Money readAmountEntry(Display & echoOn);
  };

//

Interface for class CashDispenser

class CashDispenser
  {
    /* 
     * PURPOSE: Model the ATM component that dispenses cash during withdrawls
     */

    public:

        CashDispenser();

        void setCash(Money initialCash);
        void dispenseCash(Money amount);
        Money currentCash() const;

    private:

        Money _currentCash;
  };

//

Interface for class EnvelopeAcceptor

class EnvelopeAcceptor
  {
    /* 
     * PURPOSE: Model the ATM component that accepts an envelope during deposits
     */

    public:

        EnvelopeAcceptor();

        bool acceptEnvelope();
  };

//

Interface for class ReceiptPrinter

class ReceiptPrinter
  {
    /* 
     * PURPOSE: Model the ATM component that prints receipts
     */

    public:

        ReceiptPrinter();

        void printReceipt(int theATMnumber,
                          const char * theATMlocation,
                          int cardNumber,
                          int serialNumber,
                          const char * description,
                          Money amount,
                          Money balance,
                          Money availableBalance);
  };

//

Interface for class OperatorPanel

class OperatorPanel
  {
    /* 
     * PURPOSE: Model the ATM component that allows an operator to stop
     *          the machine for maintenance
     */

    public:

        OperatorPanel();

        bool switchOn();                // True iff "on"
        Money getInitialCash();
  };

//