Vous êtes sur la page 1sur 26

Requirements Statement for Example ATM System

The software to be designed will control a simulated automated teller machine (ATM)
having a magnetic stripe reader for reading an ATM card, a customer console (keyboard
and display) for interaction with the customer, a slot for depositing envelopes, a dispenser
for cash (in multiples of $20), a printer for printing customer receipts, and a key-operated
switch to allow an operator to start or stop the machine. The ATM will communicate with
the bank's computer over an appropriate communication link. (The software on the latter
is not part of the requirements for this problem.)
The ATM will service one customer at a time. A customer will be required to insert an
ATM card and enter a personal identification number (PIN) - both of which will be sent
to the bank for validation as part of each transaction. The customer will then be able to
perform one or more transactions. The card will be retained in the machine until the
customer indicates that he/she desires no further transactions, at which point it will be
returned - except as noted below.
The ATM must be able to provide the following services to the customer:
1. A customer must be able to make a cash withdrawal from any suitable account
linked to the card, in multiples of $20.00. Approval must be obtained from the
bank before cash is dispensed.
2. A customer must be able to make a deposit to any account linked to the card,
consisting of cash and/or checks in an envelope. The customer will enter the
amount of the deposit into the ATM, subject to manual verification when the
envelope is removed from the machine by an operator. Approval must be obtained
from the bank before physically accepting the envelope.
3. A customer must be able to make a transfer of money between any two accounts
linked to the card.
4. A customer must be able to make a balance inquiry of any account linked to the
card.
A customer must be able to abort a transaction in progress by pressing the Cancel key
instead of responding to a request from the machine.
The ATM will communicate each transaction to the bank and obtain verification that it
was allowed by the bank. Ordinarily, a transaction will be considered complete by the
bank once it has been approved. In the case of a deposit, a second message will be sent to
the bank indicating that the customer has deposited the envelope. (If the customer fails to
deposit the envelope within the timeout period, or presses cancel instead, no second
message will be sent to the bank and the deposit will not be credited to the customer.)
If the bank determines that the customer's PIN is invalid, the customer will be required to
re-enter the PIN before a transaction can proceed. If the customer is unable to
successfully enter the PIN after three tries, the card will be permanently retained by the
machine, and the customer will have to contact the bank to get it back.
If a transaction fails for any reason other than an invalid PIN, the ATM will display an
explanation of the problem, and will then ask the customer whether he/she wants to do
another transaction.

The ATM will provide the customer with a printed receipt for each successful transaction,
showing the date, time, machine location, type of transaction, account(s), amount, and
ending and available balance(s) of the affected account ("to" account for transfers).
The ATM will have a key-operated switch that will allow an operator to start and stop the
servicing of customers. After turning the switch to the "on" position, the operator will be
required to verify and enter the total cash on hand. The machine can only be turned off
when it is not servicing a customer. When the switch is moved to the "off" position, the
machine will shut down, so that the operator may remove deposit envelopes and reload
the machine with cash, blank receipts, etc.
The ATM will also maintain an internal log of transactions to facilitate resolving
ambiguities arising from a hardware failure in the middle of a transaction. Entries will be
made in the log when the ATM is started up and shut down, for each message sent to the
Bank (along with the response back, if one is expected), for the dispensing of cash, and
for the receiving of an envelope. Log entries may contain card numbers and dollar
amounts, but for security will never contain a PIN.

Use Cases for Example ATM System

Flows of Events for Individual Use Cases

System Startup Use Case


The system is started up when the operator turns the operator switch to the "on" position.
The operator will be asked to enter the amount of money currently in the cash dispenser,
and a connection to the bank will be established. Then the servicing of customers can
begin.

System Shutdown Use Case


The system is shut down when the operator makes sure that no customer is using the
machine, and then turns the operator switch to the "off" position. The connection to the
bank will be shut down. Then the operator is free to remove deposited envelopes,
replenish cash and paper, etc.

Session Use Case


A session is started when a customer inserts an ATM card into the card reader slot of the
machine. The ATM pulls the card into the machine and reads it. (If the reader cannot read
the card due to improper insertion or a damaged stripe, the card is ejected, an error screen
is displayed, and the session is aborted.) The customer is asked to enter his/her PIN, and
is then allowed to perform one or more transactions, choosing from a menu of possible
types of transaction in each case. After each transaction, the customer is asked whether
he/she would like to perform another. When the customer is through performing
transactions, the card is ejected from the machine and the session ends. If a transaction is
aborted due to too many invalid PIN entries, the session is also aborted, with the card
being retained in the machine.
The customer may abort the session by pressing the Cancel key when entering a PIN or
choosing a transaction type.

Transaction Use Case


Note: Transaction is an abstract generalization. Each specific concrete type of
transaction implements certain operations in the appropriate way. The flow of events
given here describes the behavior common to all types of transaction. The flows of events
for the individual types of transaction (withdrawal, deposit, transfer, inquiry) give the
features that are specific to that type of transaction.
A transaction use case is started within a session when the customer chooses a transaction
type from a menu of options. The customer will be asked to furnish appropriate details
(e.g. account(s) involved, amount). The transaction will then be sent to the bank, along
with information from the customer's card and the PIN the customer entered.
If the bank approves the transaction, any steps needed to complete the transaction (e.g.
dispensing cash or accepting an envelope) will be performed, and then a receipt will be
printed. Then the customer will be asked whether he/she wishes to do another transaction.

If the bank reports that the customer's PIN is invalid, the Invalid PIN extension will be
performed and then an attempt will be made to continue the transaction. If the customer's
card is retained due to too many invalid PINs, the transaction will be aborted, and the
customer will not be offered the option of doing another.
If a transaction is cancelled by the customer, or fails for any reason other than repeated
entries of an invalid PIN, a screen will be displayed informing the customer of the reason
for the failure of the transaction, and then the customer will be offered the opportunity to
do another.
The customer may cancel a transaction by pressing the Cancel key as described for each
individual type of transaction below.
All messages to the bank and responses back are recorded in the ATM's log.

Withdrawal Transaction Use Case


A withdrawal transaction asks the customer to choose a type of account to withdraw from
(e.g. checking) from a menu of possible accounts, and to choose a dollar amount from a
menu of possible amounts. The system verifies that it has sufficient money on hand to
satisfy the request before sending the transaction to the bank. (If not, the customer is
informed and asked to enter a different amount.) If the transaction is approved by the
bank, the appropriate amount of cash is dispensed by the machine before it issues a
receipt. (The dispensing of cash is also recorded in the ATM's log.)
A withdrawal transaction can be cancelled by the customer pressing the Cancel key any
time prior to choosing the dollar amount.

Deposit Transaction Use Case


A deposit transaction asks the customer to choose a type of account to deposit to (e.g.
checking) from a menu of possible accounts, and to type in a dollar amount on the
keyboard. The transaction is initially sent to the bank to verify that the ATM can accept a
deposit from this customer to this account. If the transaction is approved, the machine
accepts an envelope from the customer containing cash and/or checks before it issues a
receipt. Once the envelope has been received, a second message is sent to the bank, to
confirm that the bank can credit the customer's account - contingent on manual
verification of the deposit envelope contents by an operator later. (The receipt of an
envelope is also recorded in the ATM's log.)
A deposit transaction can be cancelled by the customer pressing the Cancel key any time
prior to inserting the envelope containing the deposit. The transaction is automatically
cancelled if the customer fails to insert the envelope containing the deposit within a
reasonable period of time after being asked to do so.
Transfer Transaction Use Case
A transfer transaction asks the customer to choose a type of account to transfer from (e.g.
checking) from a menu of possible accounts, to choose a different account to transfer to,
and to type in a dollar amount on the keyboard. No further action is required once the
transaction is approved by the bank before printing the receipt.

A transfer transaction can be cancelled by the customer pressing the Cancel key any time
prior to entering a dollar amount.

Inquiry Transaction Use Case


An inquiry transaction asks the customer to choose a type of account to inquire about
from a menu of possible accounts. No further action is required once the transaction is
approved by the bank before printing the receipt.
An inquiry transaction can be cancelled by the customer pressing the Cancel key any time

Invalid PIN Extension


An invalid PIN extension is started from within a transaction when the bank reports that
the customer's transaction is disapproved due to an invalid PIN. The customer is required
to re-enter the PIN and the original request is sent to the bank again. If the bank now
approves the transaction, or disapproves it for some other reason, the original use case is
continued; otherwise the process of re-entering the PIN is repeated. Once the PIN is
successfully re-entered, it is used for both the current transaction and all subsequent
transactions in the session. If the customer fails three times to enter the correct PIN, the
card is permanently retained, a screen is displayed informing the customer of this and
suggesting he/she contact the bank, and the entire customer session is aborted.
If the customer presses cancel instead of re-entering a PIN, the original transaction is
cancelled.

Initial Functional Test Cases for Example ATM System


The following initial test cases can be identified early in the design process as a vehicle
for checking that the implementation is basically correct. No attempt has been made at
this point to do thorough testing, including all possible errors and boundary cases. That
needs to come later. These cases represent an initial check that the functionality specified
by the use cases is present.
Some writers would argue for developing test cases like these in place of use cases. Here,
they are presented as a vehicle for "fleshing out" the use cases, not as a substitute for
them.
Use Case
System
Startup
System
Startup
System
Startup

Function Being
Initial System
Tested
State
System is started
when the switch is System is off
turned "on"
System is
System accepts
requesting cash
initial cash amount
amount

Input

Expected Output

Activate the "on" System requests initial cash


switch
amount
Enter a legitimate
System is on
amount

System output should


Perform a
Connection to the System has just
demonstrate that a
legitimate inquiry
bank is established been turned on
connection has been
transaction
established to the Bank

Use Case
System
Startup
System
Shutdown
System
Shutdown
Session

Session

Session
Session

Session

Session

Transaction

Transaction

Withdrawal
Withdrawal

Function Being
Tested
System is started
when the switch is
turned "on"
System is shut
down when the
switch is turned
"off"
Connection to the
Bank is terminated
when the system is
shut down
System reads a
customer's ATM
card

Initial System
State
System is off

Input

Expected Output

Activate the "on" System requests initial cash


switch
amount

System is on and
Activate the "off"
not servicing a
System is off
switch
customer
System has just
been shut down

Verify from the bank side


that a connection to the ATM
no longer exists

System is on and
Insert a readable Card is accepted;
not servicing a
card
System asks for entry of PIN
customer
Card is ejected;
System is on and
System displays an error
System rejects an
Insert an
not servicing a
screen;
unreadable card
unreadable card
customer
System is ready to start a
new session
System accepts
System is asking
System displays a menu of
Enter a PIN
customer's PIN
for entry of PIN
transaction types
System is
System allows
System asks whether
displaying menu Perform a
customer to perform
customer wants another
of transaction
transaction
a transaction
transaction
types
System is asking
System allows
whether
multiple
System displays a menu of
customer wants Answer yes
transactions in one
transaction types
another
session
transaction
System is asking
Session ends when
whether
customer chooses
System ejects card and is
customer wants Answer no
not to do another
ready to start a new session
another
transaction
transaction
Individual types of
transaction will be
tested below
Enter an incorrect
System handles an
A readable card PIN and then
The Invalid PIN Extension is
invalid PIN
has been entered attempt a
performed
properly
transaction
System asks
Menu of
Choose
customer to choose transaction types
System displays a menu of
Withdrawal
an account to
is being
account types
transaction
withdraw from
displayed
System asks
Menu of account Choose checking System displays a menu of
customer to choose types is being
account
possible withdrawal amounts

Use Case
System
Startup

Withdrawal

Withdrawal

Withdrawal

Withdrawal

Withdrawal

Deposit
Deposit

Function Being
Initial System
Input
Expected Output
Tested
State
System is started
Activate the "on" System requests initial cash
when the switch is System is off
switch
amount
turned "on"
a dollar amount to
displayed
withdraw
System dispenses this
Choose an
amount of cash;
System is
amount that the System prints a correct
System performs a
displaying the system currently receipt showing amount and
legitimate
menu of
has and which is correct updated balance;
withdrawal
withdrawal
not greater than System records transaction
transaction properly
amounts
the account
correctly in the log (showing
balance
both message to the bank
and approval back)
System has been
started up with
less than the
maximum
Choose an
System verifies that
System displays an
withdrawal
amount greater
it has sufficient cash
appropriate message and
amount in cash than what the
on hand to fulfill
asks customer to choose a
on hand;
system currently
the request
different amount
System is
has
requesting a
withdrawal
amount
Choose an
System displays an
System verifies that System is
amount that the
appropriate message and
customer's balance requesting a
system currently
offers customer the option of
is sufficient to
withdrawal
has but which is
choosing to do another
fulfill the request ammount
greater than the
transaction or not.
account balance
A withdrawal
System displays an
transaction can be
System is
appropriate message and
cancelled by the
Press "Cancel"
displaying menu
offers customer the option of
customer any time
key
of account types
choosing to do another
prior to choosing
transaction or not.
the dollar amount
A withdrawal
System displays an
transaction can be System is
appropriate message and
cancelled by the
displaying menu Press "Cancel"
offers customer the option of
customer any time of dollar
key
choosing to do another
prior to choosing amounts
transaction or not.
the dollar amount
System asks
Menu of
customer to choose transaction types Choose Deposit System displays a menu of
an account to
is being
transaction
account types
deposit to
displayed
System asks
Menu of account Choose checking System displays a request for

Use Case
System
Startup

Deposit

Deposit

Deposit

Deposit

Deposit

Deposit

Transfer

Function Being
Initial System
Tested
State
System is started
when the switch is System is off
turned "on"
customer to enter a
types is being
dollar amount to
displayed
deposit
System is
System asks
displaying a
customer to insert request for the
an envelope
customer to type
a dollar amount

Input

Expected Output

Activate the "on" System requests initial cash


switch
amount
account

the customer to type a dollar


amount

Enter a legitimate System requests that


dollar amount
customer insert an envelope

System accepts envelope;


System prints a correct
receipt showing amount and
System is
System performs a
correct updated balance;
requesting that
legitimate deposit
Insert an envelope System records transaction
customer insert
transaction properly
correctly in the log (showing
an envelope
message to the bank,
approval back, and
acceptance of the envelope)
A deposit
System displays an
transaction can be
System is
appropriate message and
cancelled by the
Press "Cancel"
displaying menu
offers customer the option of
customer any time
key
of account types
choosing to do another
prior to inserting an
transaction or not.
envelope
A deposit
System displays an
transaction can be System is
appropriate message and
cancelled by the
requesting
Press "Cancel"
offers customer the option of
customer any time customer to enter key
choosing to do another
prior to inserting an a dollar amount
transaction or not.
envelope
A deposit
System is
System displays an
transaction can be
requesting
appropriate message and
cancelled by the
Press "Cancel"
customer to
offers customer the option of
customer any time
key
insert an
choosing to do another
prior to inserting an
envelope
transaction or not.
envelope
A deposit
transaction is
System is
System displays an
cancelled
requesting
Wait for the
appropriate message and
automatically if an customer to
request to time
offers customer the option of
envelope is not
insert an
out
choosing to do another
inserted within a
envelope
transaction or not.
reasonable time
System asks
Menu of
Choose Transfer System displays a menu of
customer to choose transaction types transaction
account types specifying
an account to
is being
transfer from

Use Case
System
Startup

Transfer

Transfer

Transfer

Transfer

Transfer

Transfer

Inquiry

Inquiry

Function Being
Tested
System is started
when the switch is
turned "on"
transfer from
System asks
customer to choose
an account to
transfer to
System asks
customer to enter a
dollar amount to
transfer

Initial System
State
System is off
displayed
Menu of account
types to transfer
from is being
displayed
Menu of account
types to transfer
to is being
displayed

Input

Expected Output

Activate the "on" System requests initial cash


switch
amount

System displays a menu of


Choose checking
account types specifying
account
transfer to
Choose savings
account

System displays a request for


the customer to type a dollar
amount

System prints a correct


System is
receipt showing amount and
System performs a displaying a
correct updated balance;
Enter a legitimate
legitimate transfer request for the
System records transaction
dollar amount
transaction properly customer to type
correctly in the log (showing
a dollar amount
both message to the bank
and approval back)
A transfer
System is
System displays an
transaction can be
displaying menu
appropriate message and
cancelled by the
Press "Cancel"
of account types
offers customer the option of
customer any time
key
specifying
choosing to do another
prior to entering
transfer from
transaction or not.
dollar amount
A transfer
System is
System displays an
transaction can be
displaying menu
appropriate message and
cancelled by the
Press "Cancel"
of account types
offers customer the option of
customer any time
key
specifying
choosing to do another
prior to entering
transfer to
transaction or not.
dollar amount
A transfer
System displays an
transaction can be System is
appropriate message and
cancelled by the
requesting
Press "Cancel"
offers customer the option of
customer any time customer to enter key
choosing to do another
prior to entering
a dollar amount
transaction or not.
dollar amount
System asks
Menu of
customer to choose transaction types Choose Inquiry System displays a menu of
an account to
is being
transaction
account types
inquire about
displayed
System prints a correct
receipt showing correct
System performs a System is
balance;
Choose checking
legitimate inquiry displaying menu
System records transaction
account
transaction properly of account types
correctly in the log (showing
both message to the bank
and approval back)

Use Case
System
Startup

Inquiry

Function Being
Initial System
Tested
State
System is started
when the switch is System is off
turned "on"
An inquiry
transaction can be
System is
cancelled by the
displaying menu
customer any time
of account types
prior to choosing an
account

Invalid PIN Customer is asked


Extension to reenter PIN

Input

Expected Output

Activate the "on" System requests initial cash


switch
amount

Press "Cancel"
key

System displays an
appropriate message and
offers customer the option of
choosing to do another
transaction or not.

Enter an incorrect
PIN;
Attempt an
Customer is asked to re-enter
inquiry
PIN
transaction on the
customer's
checking account

Request to reInvalid PIN Correct re-entry of


Original transaction
enter PIN is
Enter correct PIN
Extension PIN is accepted
completes successfully
being displayed
An incorrect PIN
A correctly rehas been reInvalid PIN entered PIN is used entered and
Perform another This transaction completes
Extension for subsequent
transaction
transaction
successfully as well
transactions
completed
normally
Request to reAn appropriate message is
Invalid PIN Incorrect re-entry of
Enter incorrect
enter PIN is
displayed and re-entry of the
Extension PIN is not accepted
PIN
being displayed
PIN is again requested
Enter incorrect
Correct re-entry of Request to reInvalid PIN
PIN the first time, Original transaction
PIN on the second enter PIN is
Extension
then correct PIN completes successfully
try is accepted
being displayed
the second time
Enter incorrect
Correct re-entry of Request to rePIN the first time
Invalid PIN
Original transaction
PIN on the third try enter PIN is
and second times,
Extension
completes successfully
is accepted
being displayed then correct PIN
the third time
Three incorrect reAn appropriate message is
entries of PIN result Request to reInvalid PIN
Enter incorrect displayed;
in retaining card
enter PIN is
Extension
PIN three times Card is retained by machine;
and aborting
being displayed
Session is terminated
transaction

Analysis Classes
An initial reading of the use cases suggests that the following will be part of the system.

A controller object representing the ATM itself (managing the boundary objects
listed below.)

Boundary objects representing the individual component parts of the ATM:


Operator panel.
Card reader.
Customer console, consisting of a display and keyboard.
Network connection to the bank.
Cash dispenser.
Envelope acceptor.
Receipt printer.
Controller objects corresponding to use cases. (Note: class ATM can handle the
Startup and Shutdown use cases itself, so these do not give rise to separate objects
here.)
Session
o Transaction (abstract generalization, responsible for common features,
with concrete specializations responsible for type-specific portions)
o
o
o
o
o
o
o

An entity object representing the information encoded on the ATM card inserted
by customer.

An entity object representing the log of transactions maintained by the machine.

This leads to the following diagram of analysis classes:


Click on a class icon to go to links to various kinds of information about it
CRC Cards for ATM Example
Using CRC cards to assign responsibilities to various classes for the tasks required by the
various use cases leads to the creation of the following cards.
The following links can be used to go directly to the CRC cards for the various classes:

Class ATM

Boundary/entity objects - component parts of the ATM

Class CardReader
Class CashDispenser
Class CustomerConsole
Class EnvelopeAcceptor
Class Log
Class NetworkToBank
Class OperatorPanel
Class ReceiptPrinter
Controller objects corresponding to the various use cases
o
o
o
o
o
o
o
o

Class Session
Class Transaction
Class Withdrawal
Class Deposit
Class Transfer
Class Inquiry
Entity objects found necessary when assigning responsibilities to other objects
o
o
o
o
o
o

o
o
o
o
o

Class Balances
Class Card
Class Message
Class Receipt
Class Status

Class ATM
Responsibilities
Start up when switch is turned on
Shut down when switch is turned off
Start a new session when card is inserted by customer

Collaborators
OperatorPanel
CashDispenser
NetworkToBank
NetworkToBank
CustomerConsole
Session

Provide access to component parts for sessions and


transactions

Class Card Reader


Responsibilities
Tell ATM when card is inserted
Read information from card
Eject card
Retain card

Collaborators
ATM
Card

Class Cash Dispenser


Responsibilities
Keep track of cash on hand, starting with initial amount
Report whether enough cash is available
Dispense cash

Collaborators

Log

Class Customer Console


Responsibilities
Display a message
Display a prompt, accept a PIN from keyboard
Display a prompt and menu, accept a choice from keyboard
Display a prompt, accept a dollar amount from keyboard
Respond to cancel key being pressed by customer

Collaborators

Class Envelope Acceptor


Responsibilities
Accept envelope from customer; report if timed out or
cancelled

Collaborators
Log

Class Log
Responsibilities
Log messages sent to bank
Log responses from bank
Log dispensing of cash
Log receiving an envelope

Collaborators

Class NetworkToBank
Responsibilities
Initiate connection to bank at startup
Send message to bank and wait for response

Collaborators
Message
Log
Balances
Status

Terminate connection to bank at shutdown

Class Operator Panel


Responsibilities
Inform ATM of changes to state of switch
Allow operator to specify amount of initial cash

Collaborators
ATM

Class Receipt Printer


Responsibilities

Collaborators
Receipt

Responsibilities
Perform session use case

Collaborators

Print receipt

Class Session
ATM
CardReader
Card
CustomerConsole
Transaction

Update PIN value if customer has to re-enter it

Abstract Class Transaction


Responsibilities
Allow customer to choose a type of transaction

Collaborators
ATM
CustomerConsole
Withdrawal
Deposit
Transfer
Inquiry

Perform Transaction Use Case

Perform invalid PIN extension

ATM
CustomerConsole
Withdrawal
Deposit
Transfer
Inquiry
Message
NetworkToBank
Receipt
ReceiptPrinter
CustomerConsole
Session
CardReader

Class Withdrawal
Responsibilities
Collaborators
Perform operations peculiar to withdrawal transaction use case CustomerConsole
CashDispenser
Message
Receipt

Class Deposit
Responsibilities
Perform operations peculiar to deposit transaction use case

Collaborators
CustomerConsole
Message
EnvelopeAcceptor
Receipt

Class Transfer
Responsibilities
Perform operations peculiar to transfer transaction use case

Collaborators
CustomerConsole
Message
Receipt

Class Inquiry
Responsibilities
Perform operations peculiar to inquiry transaction use case

Collaborators
CustomerConsole
Message
Receipt

Class Balances
Responsibilities
Represent account balance information returned by bank

Collaborators

Class Card
Responsibilities
Represent information encoded on customer's ATM card

Collaborators

Class Message
Responsibilities
Represent information to be sent over network to bank

Collaborators

Class Receipt
Responsibilities
Represent information to be printed on a receipt

Collaborators

Class Status
Responsibilities
Represent transaction status information returned by bank

Collaborators

Class Diagram for Example ATM System


Shown below is the class diagram for the ATM system. The basic structure of the class
diagram arises from the responsibilities and relationships discovered when doing the
CRC cards and Interaction Diagrams. (If a class uses another class as a collaborator, or
sends a message to an object of that class during an Interaction, then there must either be
an association linking objects of those classes, or linking the "sending" class to an object
which provides access to an object of the "receiving" class.)
In the case of the ATM system, one of the responsibilities of the ATM is to provide access
to its component parts for Session and Transaction objects; thus, Session and Transaction
have associations to ATM, which in turn has associations to the classes representing the
individual component parts. (Explicit "uses" links between Session and Transaction, on
the one hand, and the component parts of the ATM, on the other hand, have been omitted
from the diagram to avoid making it excessively cluttered.)
The need for the various classes in the diagram was discovered at various points in the
design process.

Some classes were discovered when doing analysis (see the Analysis Class
Diagram developed earlier.)

Some classes were discovered when doing CRC cards

o
o
o
o

Message - used to represent a message to the bank.


Receipt - used to encapsulate information to be printed on a receipt.
Status - used to represent return value from message to the bank.
Balances - used to record balance information returned by the bank.

Some classes were discovered when doing detailed design or writing code
o
o

Money - used to represent money amounts, in numerous places.


AccountInformation - contains names of various types of accounts
customer can choose from

That is, OO design is not a "waterfall" process - discoveries made when doing detailed
design and coding can impact overall system design.
To prevent the diagram from becoming overly large, only the name of each class is
shown - the attribute and behavior "compartments" are shown in the detailed design, but
are omitted here.

Click on a class icon for links to further information about it

Detailed Design
A major task of detailed design is to spell out, in detail, the attributes and methods needed
by each class (the second and third "compartments" of the representation for each class in
a class diagram.)
The methods needed by each class are implicit in the responsibilities assigned to the class
in the CRC cards, and become explicit in the Interaction Diagrams. A responsibility listed
for a class on its CRC card generally maps into a method or methods in the detailed

design. Likewise, any time an object belonging to a given class is shown as the recipient
of a message in either a Sequence or Collaboration Diagram, the class needs a
corresponding method. Many of the needed attributes are also either explicitly or
implicitly present in the diagrams; the need for others becomes evident as the code for the
class is being written. (Thus detailed design and coding are a "round trip" process detailed design dictates coding, and coding leads to elaboration of the detailed design.)
In designing this system, a few key design decisions were made:

The class ATM is made an active class - that is, the ATM object has its own
thread. Using the Java thread facllity leads to defining a run() method in this class
whose body is executed by the ATM's thread. The fact that class ATM is active is
indicated in class diagrams by enclosing it in a heavier outline.

Certain signals initiate computation - e.g. the signals from the operator console
when the state of the switch is changed, or from the card reader when a card is
inserted. In the GUI simulation of the ATM, these signals are sent by the
"actionPerformed()" method of the appropriate GUI button; in a real ATM they
would be sent by the physical components themselves, which might then also
need to be active classes. (Note: this forms an exception to the rule that a
responsibility on a CRC card translates into a method in the design - in this case
the class sends a signal, rather than receiving it, so it does not need a method
directly corresponding to the responsibility.)

The Transaction hierarchy consists of the abstract class Transaction and four
concrete subclasses (Withdrawal, Deposit, Transfer and Inquiry). The class
Transaction has a "virtual constructor" called makeTransaction() which asks the
customer to choose a transaction type and then constructs and returns an object of
the appropriate subclass. The Transaction class is made responsible for carrying
out the Transaction use case and the Invalid PIN extension; for the former, it
makes use of abstract methods getSpecificsFromCustomer() and
completeTransaction() which are implemented concretely by each subclass.

The class Receipt is abstract. The completeTransaction() method of each kind of


transaction creates a concrete instance that contains the information relevant to
that kind of transaction.

The class Status is abstract. The send() method of NetworkToBank constructs a


concrete instance that contains the information appropriate to the response
received from the bank to a particular message.

In the design below, each class is developed in isolation. No attempt is made to connect
each class to related classes as in the class diagram, because the resulting picture would
not fit on a displayable web page. Therefore, this detailed design should be viewed in
conjunction with the Class Diagram developed earlier.

Detailed design for class ATM

Component parts of the ATM


o

Detailed design for class CardReader

o
o
o
o
o
o
o

Detailed design for class CashDispenser


Detailed design for class CustomerConsole
Detailed design for class EnvelopeAcceptor
Detailed design for class Log
Detailed design for class NetworkToBank
Detailed design for class OperatorPanel
Detailed design for class ReceiptPrinter

Detailed design for class Session

The Transaction class hierarchy


o
o
o
o
o

Detailed design for class Transaction


Detailed design for class Withdrawal
Detailed design for class Deposit
Detailed design for class Transfer
Detailed design for class Inquiry

Classes representing banking concepts, used by the above


o
o
o
o
o
o
o

Detailed design for class AccountInformation


Detailed design for class Balances
Detailed design for class Card
Detailed design for class Message
Detailed design for class Money
Detailed design for class Receipt
Detailed design for class Status

ATM
- id: int
- place: String
- bankName: String
- bankAddress: InetAddress
- cardReader: CardReader
- cashDispenser: CashDispenser
- customerConsole: CustomerConsole
- envelopeAcceptor: EnvelopeAcceptor
- log: Log
- networkToBank: NetworkToBank
- operatorPanel: OperatorPanel
- receiptPrinter: ReceiptPrinter

- state: int
- switchOn: boolean
- cardInserted: boolean
- OFF_STATE: final int
- IDLE_STATE: final int
- SERVING_CUSTOMER_STATE: final int
+ ATM(id: int, place: String, bankName: String, bankAddress: InetAddress)
+ run()
+ switchOn()
+ switchOff
+ cardInserted()
+ getID(): int
+ getPlace(): String
+ getBankName(): String
+ getCardReader(): CardReader
+ getCashDispenser(): CashDispenser
+ getCustomerConsole(): CustomerConsole
+ getEnvelopeAcceptor(): EnvelopeAcceptor
+ getLog(): Log
+ getNetworkToBank(): NetworkToBank
+ getOperatorPanel(): OperatorPanel
+ getReceiptPrinter(): ReceiptPrinter
- performStartup()
- performShutdown()
CardReader
- atm: ATM
+ CardReader(atm: ATM)
+ readCard(): Card
+ ejectCard()
+ retainCard()

CashDispenser
- log: Log
- cashOnHand: Money
+ CashDispenser(log: Log)
+ setInitialCash(initialCash: Money)
+ checkCashOnHand(amount: Money): boolean
+ dispenseCash(amount: Money)

CustomerConsole

+ CustomerConsole()
+ display(message: String)
+ readPIN(prompt: String): int throws Cancelled
+ readMenuChoice(prompt: String, menu: String []): int throws Cancelled
+ readAmount(prompt: String): Money throws Cancelled
EnvelopeAcceptor
- log: Log
+ EnvelopeAcceptor(log: Log)
+ acceptEnvelope() throws Cancelled
Log

+ Log()
+ logSend(message: Message)
+ logResponse(status: Status)
+ logCashDispensed(amount: Money)
+ logEnvelopeAccepted()
NetworkToBank
- log: Log
- bankAddress: InetAddress
+ NetworkToBank(log: Log, bankAddress: InetAddress)
+ openConnection()
+ closeConnection()
+ sendMessage(message: Message, out balances: Balances): Status
OperatorPanel
- atm: ATM
+ OperatorPanel(atm: ATM)
+ getInitialCash(): Money
ReceiptPrinter

+ ReceiptPrinter()
+ printReceipt(receipt: Receipt)
Session
- atm: ATM
- pin: int

- state: int
- READING_CARD_STATE: final int
- READING_PIN_STATE: final int
- CHOOSING_TRANSACTION_STATE: final int
- PERFORMING_TRANSACTION_STATE: final int
- EJECTING_CARD_STATE: final int
- FINAL_STATE: final int
+ Session(atm: ATM)>
+ performSession()
+ setPIN(int pin)
Transaction
# atm: ATM
# session: Session
# card: Card
# pin: int
# serialNumber: int
# message: Message
# balances: Balances
- TRANSACTION_TYPES_MENU: final String []
- nextSerialNumber: int
- state: int
- GETTING_SPECIFICS_STATE: final int
- SENDING_TO_BANK_STATE: final int
- INVALID_PIN_STATE: final int
- COMPLETING_TRANSACTION_STATE: final int
- PRINTING_RECEIPT_STATE: final int
- ASKING_DO_ANOTHER_STATE: final int
# Transaction(atm: ATM, session: Session, card: Card, pin: int)
+ makeTransaction(atm: ATM, session: Session, card: Card, pin: int): Transaction throws
Cancelled
+ performTransaction(): boolean throws CardRetained
+ performInvalidPinExtension(): Status throws Cancelled, CardRetained
+ getSerialNumber(): int
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt throws Cancelled
Withdrawal
- from: int
- amount: Money
+ Withdrawal(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt

Deposit
- to: int
- amount: Money
+ Deposit(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt throws Cancelled
Transfer
- from: int
- to: int
- amount: Money
+ Transfer(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt
Inquiry
- from: int
+ Inquiry(atm: ATM, session: Session, card: Card, pin: int)
# getSpecificsFromCustomer(): Message throws Cancelled
# completeTransaction(): Receipt
AccountInformation
+ ACCOUNT_NAMES: final String[]
+ ACCOUNT_ABBREVIATIONS: final String []
Balances
- total: Money
- available: Money
+ Balances()
+ setBalances(total: Money, available: Money)
+ getTotal(): Money
+ getAvailable(): Money
Card
- number: int
+ Card(number: int)
+ getNumber(): int
Message

+ WITHDRAWAL: final int


+ INITIATE_DEPOSIT: final int
+ COMPLETE_DEPOSIT: final int
+ TRANSFER: final int
+ INQUIRY: final int
- messageCode: int
- card: Card
- pin: int
- serialNumber: int
- fromAccount: int
- toAccount: int
- amount: int
+ Message(messageCode: int, cardNumber: Card, pin: int, serialNumber: int,
fromAccount: int, toAccount: int, amount: Money)
+ toString(): String
+ setPIN(pin: int)
+ getMessageCode(): int
+ getCard(): Card
+ getPIN(): int
+ getSerialNumber(): int
+ getFromAccount(): int
+ getToAccount(): int
+ getAmount(): Money
Money
- cents: long
+ Money(dollars: int)
+ Money(dollars: int, cents: int)
+ Money(toCopy: Money)
+ toString(): String
+ add(amountToAdd: Money)
+ subtract(amountToSubtract: Money)
+ lessEqual(compareTo: Money): boolean
Receipt
- headingPortion: String []
# detailsPortion(): String []
- balancesPortion: String []
# Receipt(atm: ATM, card: Card, transaction: Transaction, balances: Balances)
+ getLines(): Enumeration
Status

+ toString(): String
+ isSuccess(): boolean
+ isInvalidPIN(): boolean
+ getMessage(): String

Vous aimerez peut-être aussi