ATM Problem Operation Description Forms

  1. Operations of class ATM - which has the following components:
    1. Operations of class CardReader
    2. Operations of class Display
    3. Operations of class Keyboard
    4. Operations of class CashDispenser
    5. Operations of class EnvelopeAcceptor
    6. Operations of class ReceiptPrinter
    7. Operations of class OperatorPanel
  2. Operations of class Session
  3. Operations of class Transaction and its subclasses
  4. Operations of class Bank

 

[ Intro ] [ Requirements ] [ Domain Objects ] [ Use Cases ] [ CRC Cards ] [ Class Diagram ]
[ Class Description Forms ] [ Operation Description Forms ] [ Code ] [ Executable ]

 

Copyright © 1996 - Russell C. Bjork. Permission for non-commercial reproduction for educational use is hereby granted; all other rights are reserved.

 


Operations of class ATM


ATM::ATM
Prototype ATM(int number, const char * location)
Purpose Constructor
Receives number - the ATM's number
location - the ATM's location
Returns
Remarks

[ View C++ implementation ]


ATM::startupOperation
Prototype Money startupOperation()
Purpose Perform startup tasks when the ATM's switch is turned on
Receives
Returns Initial cash in the cash dispenser
Remarks Waits for operator to turn switch on.
Sets _state to RUNNING.
Asks operator how much cash is in the dispenser.

[ View C++ implementation ]


ATM::serviceCustomers
Prototype void serviceCustomers(Money initialCash)
Purpose Run the ATM until the switch is turned off
Receives initialCash - amount of money in cash dispenser to start
Returns
Remarks Creates a new Session when a readable card is inserted.
Polls operator switch when no session is active,
sets _state to STOPPED and exits when switch is turned off.

[ View C++ implementation ]


ATM::getPIN
Prototype int getPIN() const
Purpose Get personal identification number (PIN) from customer
Receives
Returns PIN entered by customer
Remarks Displays request on screen, then reads PIN from keyboard.
PIN digits are echoed as asterisks to preserve secrecy.

[ View C++ implementation ]


ATM::getTransactionChoice
Prototype Transaction::TransactionType getTransactionChoice() const
Purpose Get choice of transaction type from customer
Receives
Returns Customer choice from list of options
Remarks Displays list of choices, then requests customer to choose
one using keyboard.

[ View C++ implementation ]


ATM::getDoAnotherTransactionChoice
Prototype bool getDoAnotherTransactionChoice() const
Purpose Ask customer if he/she wants to do another transaction
Receives
Returns True iff customer chooses yes
Remarks Displays question, then asks customer to choose yes or no
using keyboard.

[ View C++ implementation ]


ATM::getAccountChoice
Prototype Bank::AccountType getAccountChoice(const char * purpose) const
Purpose Ask customer to choose an account for a specified purpose (e.g. withdraw from, transfer to, etc.)
Receives purpose - brief description of what the account chosen is to be used for
Returns Customer choice from a list of options
Remarks Displays purpose and list of choices, then asks customer to choose one using keyboard

[ View C++ implementation ]


ATM::getWithdrawlAmountChoice
Prototype Money getWithdrawlAmountChoice() const
Purpose Ask customer to choose amount for a cash withdrawl.
Receives
Returns Customer choice from a list of options.
Remarks Displays a list of possible amounts and asks customer to choose one using keyboard.

[ View C++ implementation ]


ATM::getAmountEntry
Prototype Money getAmountEntry() const
Purpose Ask customer to enter an amount of money for a deposit, etc.
Receives
Returns Amount of money customer entered.
Remarks Asks user to enter amount, then reads amount typed at keyboard.

[ View C++ implementation ]


ATM::checkIfCashAvailable
Prototype bool checkIfCashAvailable(Money amount) const
Purpose Determine if cash dispenser has enough cash left to satisfy
a withdrawl request
Receives amount - amount desired
Returns True iff requested amount is available.
Remarks

[ View C++ implementation ]


ATM::dispenseCash
Prototype void dispenseCash(Money amount) const
Purpose Dispense cash to customer
Receives amount - amount of money to dispense
Returns
Remarks Caller must check that requested amount is available before
invoking this method.

[ View C++ implementation ]


ATM::acceptEnvelope
Prototype bool acceptEnvelope() const
Purpose Accept a deposit envelope from customer.
Receives
Returns True iff envelope is successfully accepted.
Remarks Displays request for customer to insert envelope and waits
for customer to do so.
Times out if customer does not do so within a specified time.

[ View C++ implementation ]


ATM::issueReceipt
Prototype void issueReceipt(
int cardNumber,
int serialNumber,
const char * description,
Money amount,
Money balance,
Money availableBalance) const
Purpose Print a receipt for a transaction.
Receives cardNumber - number appearing on customer's card
serialNumber - transaction serial number - same as sent to bank
description - brief description of transaction
amount - amount of transaction - 0 if this does not apply
balance - balance in account after transaction
availableBalance - available balance after transaction
Returns
Remarks

[ View C++ implementation ]


ATM::reEnterPIN
Prototype int reEnterPIN() const
Purpose Ask customer to re-enter PIN if PIN entered originally was not valid
Receives
Returns PIN entered by customer
Remarks Displays request for customer to re-enter PIN,
then reads PIN from keyboard.
PIN digits are echoed as asterisks to preserve secrecy.

[ View C++ implementation ]


ATM::reportRejection
Prototype void reportRejection(const char * reason) const
Purpose Tell customer that the bank has rejected the transaction
for some specific reason.
Receives reason - brief explanation of reason for rejection
Returns
Remarks

[ View C++ implementation ]


ATM::ejectCard
Prototype void ejectCard() const
Purpose Return ATM card to customer at end of session.
Receives
Returns
Remarks

[ View C++ implementation ]


ATM::retainCard
Prototype void retainCard() const
Purpose Permanently retain card due to failure to enter correct PIN.
Receives
Returns
Remarks Displays screen telling customer the card has been retained
and instructing customer to contact the bank.

[ View C++ implementation ]


ATM::number
Prototype int number() const
Purpose Provide the ATM's identifying number for inclusion
in messages to the bank and on receipts.
Receives
Returns ATM's identifying number
Remarks

[ View C++ implementation ]


Operations of class CardReader


CardReader::CardReader
Prototype CardReader()
Purpose Constructor
Receives
Returns
Remarks

CardReader::ejectCard
Prototype void ejectCard()
Purpose Physically eject customer's ATM card.
Receives
Returns
Remarks

CardReader::retainCard
Prototype void retainCard()
Purpose Physically retain customer's ATM card.
Receives
Returns
Remarks

CardReader::checkForCardInserted
Prototype CardReader::ReaderStatus checkForCardInserted()
Purpose Report whether or not a readable card has been inserted.
Receives
Returns NO_CARD if no card has been inserted
UNREADABLE_CARD if a card has been inserted incorrectly
  or is damaged
CARD_HAS_BEEN_READ if a card has been inserted and read
Remarks

CardReader::cardNumber
Prototype int cardNumber() const
Purpose Return number read from back of card.
Receives
Returns Card number of card that is currently in the machine.
Remarks Should only be called after a call to checkForCardInserted
has returned CARD_HAS_BEEN_READ.

Operations of class Display


Display::Display
Prototype Display()
Purpose Constructor
Receives
Returns
Remarks

Display::displayScreen
Prototype void displayScreen(
Screen whichScreen,
const char * extraInfo = NULL)
Purpose Display specific information on the display.
Receives whichScreen - code indicating which screen to display
extraInfo - additional text to incorporate into the screen
Returns
Remarks

Display::clearDisplay
Prototype void clearDisplay()
Purpose Clear the display Screen
Receives
Returns
Remarks

Operations of class Keyboard


Keyboard::Keyboard
Prototype Keyboard()
Purpose Constructor
Receives
Returns
Remarks

Keyboard::readPIN
Prototype int readPIN()
Purpose Read a PIN typed in by the user.
Receives
Returns PIN the user typed.
Remarks PIN is echoed as asterisks for security.

Keyboard::readTransactionChoice
Prototype Transaction::TransactionType readTransactionChoice()
Purpose Allow customer to choose a specific transaction type from
displayed menu
Receives
Returns Code of customer's choice
Remarks

Keyboard::readDoAnotherTransactionChoice
Prototype bool readDoAnotherTransactionChoice()
Purpose Allow customer to choose "yes" or "no" for wanting to do
another transaction.
Receives
Returns True iff customer chose yes.
Remarks

Keyboard::readAccountChoice
Prototype Bank::AccountType readAccountChoice()
Purpose Allow customer to choose an account type from
displayed menu
Receives
Returns Code of customer's choice
Remarks

Keyboard::readWithdrawlAmountChoice
Prototype Money readWithdrawlAmountChoice()
Purpose Allow customer to choose a cash withdrawl amount from a displayed menu
Receives
Returns Dollar amount of customer's choice.
Remarks

Keyboard::readAmountEntry
Prototype Money readAmountEntry()
Purpose Allow customer to enter a dollar amount.
Receives
Returns Dollar amount entered by customer.
Remarks Dollar amount is echoed on screen as customer types it.

Keyboard::pressEnterToContinue
Prototype void pressEnterToContinue()
Purpose Allow customer to read one screen (normally one reporting an error)
before a new screen is displayed.
Receives
Returns
Remarks Returns to caller when customer presses ENTER key.

Operations of class CashDispenser


CashDispenser::CashDispenser
Prototype CashDispenser()
Purpose Constructor
Receives
Returns
Remarks

CashDispenser::setCash
Prototype void setCash(Money initialCash)
Purpose Set amount of cash in dispenser at start of run.
Receives initialCash - amount of money in dispenser
Returns
Remarks

CashDispenser::dispenseCash
Prototype void dispenseCash(Money amount)
Purpose Physically dispense cash to customer
Receives amount - amount of cash to dispense
Returns
Remarks

CashDispenser::currentCash
Prototype Money currentCash() const
Purpose Report amount of cash currently available to be dispensed.
Receives
Returns Amount of cash currently available to be dispensed.
Remarks

Operations of class EnvelopeAcceptor


EnvelopeAcceptor::EnvelopeAcceptor
Prototype EnvelopeAcceptor()
Purpose Constructor
Receives
Returns
Remarks

EnvelopeAcceptor::acceptEnvelope
Prototype bool acceptEnvelope()
Purpose Physically accept an envelope from customer.
Receives
Returns True iff envelope is successfully accepted.
Remarks Times out and returns false if envelope is not inserted
within allowed time

Operations of class ReceiptPrinter


ReceiptPrinter::ReceiptPrinter
Prototype ReceiptPrinter()
Purpose Constructor
Receives
Returns
Remarks

ReceiptPrinter::printReceipt
Prototype void printReceipt(
int theATMnumber,
const char * theATMlocation,
int cardNumber,
int serialNumber,
const char * description,
Money amount,
Money balance,
Money availableBalance)
Purpose Physically print a receipt.
Receives theATMnumber - number of the particular ATM
theATMlocation - location of the ATM
cardNumber - number appearing on customer's card
serialNumber - transaction serial number - same as sent to bank
description - brief description of transaction
amount - amount of transaction - 0 if this does not apply
balance - balance in account after transaction
availableBalance - available balance after transaction
Returns
Remarks

Operations of class OperatorPanel


OperatorPanel::OperatorPanel
Prototype OperatorPanel()
Purpose Constructor
Receives
Returns
Remarks

OperatorPanel::switchOn
Prototype bool switchOn()
Purpose Report physical setting of the switch.
Receives
Returns True iff switch is in the "on" position
Remarks

OperatorPanel::getInitialCash
Prototype Money getInitialCash()
Purpose Get amount of cash in cash dispenser from operator.
Receives
Returns Amount of money in cash dispenser.
Remarks

Operations of class Session


Session::Session
Prototype Session(int cardNumber)
Purpose Constructor
Receives cardNumber - card number read from customer's ATM card
when it was inserted
Returns
Remarks

[ View C++ implementation ]


Session::doSessionUseCase
Prototype void doSessionUseCase()
Purpose Implement session use case
Receives
Returns
Remarks

[ View C++ implementation ]


Session::doInvalidPINExtension
Prototype Bank::ApprovalCode doInvalidPINExtension()
Purpose Perform invalid PIN extension
Receives
Returns Result of sending transaction to bank with newly entered PIN value
Remarks Asks user to re-enter PIN and then re-sends current transaction
to the bank.
If the bank still says the PIN is invalid, this process is repeated
up to a maximum of three tries.
A third failure will result in the card being retained
and the session being aborted.

[ View C++ implementation ]


Session::cardNumber
Prototype int cardNumber() const
Purpose Return customer's ATM card number.
Receives
Returns Customer's ATM card number.
Remarks

[ View C++ implementation ]


Session::PIN
Prototype int PIN() const
Purpose Return PIN that customer entered at start of session
(or re-entered if original was invalid.)
Receives
Returns PIN entered by customer.
Remarks

[ View C++ implementation ]


Operations of class Transaction and its subclasses


Transaction::Transaction
Prototype Transaction(Session & session)
Purpose Constructor
Receives session - reference to session which is creating this transaction
Returns
Remarks

[ View C++ implementation ]


Transaction::makeTransaction
Prototype static Transaction * makeTransaction(
TransactionType type,
Session & session)
Purpose Create a transaction object of the appropriate subclass as specified
Receives type - specific type of transaction to be created
session - reference to session which is creating this transaction
Returns Newly created transaction object
Remarks Calls constructor for appropriate subclass and returns result

[ View C++ implementation ]


Transaction::doTransactionUseCase
Prototype void doTransactionUseCase()
Purpose Carry out transaction use case
Receives
Returns
Remarks This method implements features common to all transactions.
The type-specific features are implemented by calling the three
abstract methods defined below, in turn.

[ View C++ implementation ]


Transaction:: and subclasses getTransactionSpecificsFromCustomer
Prototype bool getTransactionSpecificsFromCustomer()
Purpose Get specific information relevant to this transaction from customer.
Receives
Returns True iff usable information was obtained.
Remarks This method is abstract in class Transaction, and is implemented
concretely for each of its subclasses.

[ View C++ implementation ]


Transaction:: and subclasses sendToBank
Prototype Bank::ApprovalCode sendToBank()
Purpose Send transaction to bank.
Receives
Returns ApprovalCode returned by bank.
Remarks
Remarks This method is abstract in class Transaction, and is implemented
concretely for each of its subclasses.

[ View C++ implementation ]


Transaction:: and subclasses finishApprovedTransaction
Prototype void finishApprovedTransaction()
Purpose Finish a transaction once the bank has approved it.
Receives
Returns
Remarks
Remarks This method is abstract in class Transaction, and is implemented
concretely for each of its subclasses.

[ View C++ implementation ]


WithdrawlTransaction::WithdrawlTransaction
Prototype WithdrawlTransaction(Session & session)
Purpose Constructor
Receives session - reference to session which created this transaction
Returns
Remarks

[ View C++ implementation ]


DepositTransaction::DepositTransaction
Prototype DepositTransaction(Session & session)
Purpose Constructor
Receives session - reference to session which created this transaction
Returns
Remarks

[ View C++ implementation ]


TransferTransaction::TransferTransaction
Prototype TransferTransaction(Session & session)
Purpose Constructor
Receives session - reference to session which created this transaction
Returns
Remarks

[ View C++ implementation ]


InquiryTransaction::InquiryTransaction
Prototype InquiryTransaction(Session & session)
Purpose Constructor
Receives session - reference to session which created this transaction
Returns
Remarks

[ View C++ implementation ]


Operations of class Bank


Bank::Bank
Prototype Bank()
Purpose Constructor
Receives
Returns
Remarks

Bank::initiateWithdrawl
Prototype ApprovalCode initiateWithdrawl(
int cardNumber,
int PIN,
int ATMnumber,
int serialNumber,
AccountType from,
Money amount,
Money & newBalance,
Money & availableBalance)
Purpose Initiate a withdrawl transaction.
Receives cardNumber - number of the customer's ATM Card
PIN - PIN entered by the customer
ATMnumber - Identifying number of the ATM
serialNumber - Serial number of the transaction assigned by ATM
from - account from which money is to be withdrawn
amount - amount of withdrawl
Returns return value - indicates whether transaction was approved or rejected
  by the bank, and the reason for rejection if this is the case.
newBalance - if the transaction is approved, this is set to balance in
  account after the transaction
availableBalance - if the transaction is approved, this is set to available
  balance in account after the transaction
Remarks If the transaction is approved, a call to finishWithdrawl must
be done to indicate whether or not the transaction was physically
completed.

Bank::finishWithdrawl
Prototype void finishWithdrawl(
int ATMnumber,
int serialNumber,
bool succeeded)
Purpose Inform bank whether or not a withdrawl transaction was physically
completed by the ATM.
Receives ATMnumber - Identifying number of the ATM
serialNumber - Serial number of the transaction assigned by ATM
succeeded - true iff transaction was physically completed by the ATM
Returns
Remarks

Bank::initiateDeposit
Prototype ApprovalCode initiateDeposit(
int cardNumber,
int PIN,
int ATMnumber,
int serialNumber,
AccountType to,
Money amount,
Money & newBalance,
Money & availableBalance)
Purpose Initiate a deposit transaction.
Receives cardNumber - number of the customer's ATM Card
PIN - PIN entered by the customer
ATMnumber - Identifying number of the ATM
serialNumber - Serial number of the transaction assigned by ATM
to - account to which money is to be deposited
amount - amount of deposit
Returns return value - indicates whether transaction was approved or rejected
  by the bank, and the reason for rejection if this is the case.
newBalance - if the transaction is approved, this is set to balance in
  account after the transaction
availableBalance - if the transaction is approved, this is set to available
  balance in account after the transaction.
Remarks If the transaction is approved, a call to finishDeposit must be done to
indicate whether or not the transaction was physically completed.

Bank::finishDeposit
Prototype void finishDeposit(
int ATMnumber,
int serialNumber,
bool succeeded)
Purpose Inform bank whether or not a deposit transaction was physically
completed by the ATM.
Receives ATMnumber - Identifying number of the ATM
serialNumber - Serial number of the transaction assigned by ATM
succeeded - true iff transaction was physically completed by the ATM
Returns
Remarks

Bank::doTransfer
Prototype ApprovalCode doTransfer(
int cardNumber,
int PIN,
int ATMnumber,
int serialNumber,
AccountType from,
AccountType to,
Money amount,
Money & newBalance,
Money & availableBalance)
Purpose Perform a transfer transaction.
Receives cardNumber - number of the customer's ATM Card
PIN - PIN entered by the customer
ATMnumber - Identifying number of the ATM
serialNumber - Serial number of the transaction assigned by ATM
from - account from which money is to be transferred
to - account to which money is to be transferred
amount - amount of transfer
Returns return value - indicates whether transaction was approved or rejected
  by the bank, and the reason for rejection if this is the case.
newBalance - if the transaction is approved, this is set to balance in
 "to" account after the transaction
availableBalance - if the transaction is approved, this is set to
  available balance in "to" account after the transaction.
Remarks If the transaction is approved, it is completed by this operation.
No second method call is needed for this case.

Bank::doInquiry
Prototype ApprovalCode doInquiry(
int cardNumber,
int PIN,
int ATMnumber,
int serialNumber,
AccountType from,
Money &newBalance,
Money & availableBalance)
Purpose Perform an inquiry transaction.
Receives cardNumber - number of the customer's ATM Card
PIN - PIN entered by the customer
ATMnumber - Identifying number of the ATM
serialNumber - Serial number of the transaction assigned by ATM
from - account whose balance is desired
Returns return value - indicates whether transaction was approved or rejected
  by the bank, and the reason for rejection if this is the case.
newBalance - if the transaction is approved, this is set to
 balance in account
availableBalance - if the transaction is approved, this is set to available
 balance in account.
Remarks If the transaction is approved, it is completed by this operation.
No second method call is needed for this case.

Bank::accountName
Prototype const char * accountName(AccountType type) const
Purpose Return a short name for an account for printing on receipt.
Receives type - account type whose name is desired
Returns Printable name for account
Remarks

Bank::rejectionDescription
Prototype const char * rejectionDescription(ApprovalCode code) const
Purpose Return a brief textual explanation of a particular rejection code
the bank returned when a transaction was initiated.
Receives code - the rejection code the bank returned
Returns Explanation for the code.
Remarks