+ All Categories
Home > Documents > Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis...

Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis...

Date post: 10-Jul-2020
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
7
Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011 Classes- Entity Types Attributes we show how these attributes represent an object's state identify some key states that our objects may occupy and discuss how objects change state in response to various events occurring in the system discuss the workflow workflow workflow workflow, or activities, activities, activities, activities, that objects perform in the ATM system. BalanceInquiry BalanceInquiry BalanceInquiry BalanceInquiry and Withdrawal Withdrawal Withdrawal Withdrawal Transaction Today: we determine some of the class operations (or behaviors) we determine some of the class operations (or behaviors) we determine some of the class operations (or behaviors) we determine some of the class operations (or behaviors) needed to implement the ATM system. needed to implement the ATM system. needed to implement the ATM system. needed to implement the ATM system.
Transcript
Page 1: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

Evangelos TheodoridisCEID - University of Patras

Object Oriented Programming II (C++)Fall 2010-2011

� Classes- Entity Types

� Attributes

� we show how these attributes represent an object's state

� identify some key states that our objects may occupy and discuss how objects change state in response to various events occurring in the systemevents occurring in the system

� discuss the workflowworkflowworkflowworkflow, or activities, activities, activities, activities, that objects perform in the ATM system. BalanceInquiryBalanceInquiryBalanceInquiryBalanceInquiry and WithdrawalWithdrawalWithdrawalWithdrawal Transaction

� Today:

◦ we determine some of the class operations (or behaviors) we determine some of the class operations (or behaviors) we determine some of the class operations (or behaviors) we determine some of the class operations (or behaviors) needed to implement the ATM system.needed to implement the ATM system.needed to implement the ATM system.needed to implement the ATM system.

Page 2: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

� An operation is a service that objects of a class provide to clients of the class.

� We can derive many of the operations of each class by examining the key verbs and verb phrases in the requirements document. We phrases in the requirements document. We then relate each of these to particular classes in our system

ClassClassClassClass Verbs and verb phrasesVerbs and verb phrasesVerbs and verb phrasesVerbs and verb phrases

ATM executes financial transactions

BalanceInquiry [none in the requirements document]

Withdrawal [none in the requirements document]

Deposit [none in the requirements document]

BankDatabase authenticates a user, retrieves an account balance,BankDatabase authenticates a user, retrieves an account balance,credits a deposit amount to an account, debits awithdrawal amount from an account

Account retrieves an account balance, credits a depositamount to an account, debits a withdrawal amountfrom an account

Screen displays a message to the user

Keypad receives numeric input from the user

CashDispenser dispenses cash, indicates whether it contains enough cash to satisfy a withdrawal request

DepositSlot receives a deposit envelope

Page 3: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

� To identify operations, we examine the verb phrases listed for each class

� The "executes financial transactions" phrase associated with class ATM implies that class ATM instructs transactions to execute. ATM instructs transactions to execute. Therefore, classes BalanceInquiryBalanceInquiryBalanceInquiryBalanceInquiry, WithdrawalWithdrawalWithdrawalWithdrawaland Deposit each need an operation to provide this service to the ATM.

Page 4: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

� Class BankDatabase needs an operation that provides an authentication service to the ATM

� class Account must provide a service to validate a PIN obtained through user input against a PIN stored in an Account objectagainst a PIN stored in an Account object

� …

� one operation that can display any message specified by a parameter thus this operation (displayMessage) is added

Page 5: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

� class Keypad should perform a getInputoperation.

� CashDispenser◦ create operation dispenseCash

◦ isSufficientCashAvailable, an operation that returns a value of UML type Boolean

� DepositSlot◦ place an operation isEnvelopeReceived, which

returns a Boolean value, in the third compartment of class

Page 6: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

� we specify that operation authenticateUsertakes integer parameters userAccountNumberand userPIN

� authenticateUser takes two parametersuserAccountNumber and userPIN, parametersuserAccountNumber and userPIN, both of type Integer

� Class BankDatabase operations getAvailableBalance, getTotalBalance, credit and debit also each require a userAccountNumber parameter to identify the account to which the database must apply the account to which the database must apply the operations

� operations credit and debit each require a Double parameter amount

Page 7: Evangelos Theodoridis CEID - University of Patras Object Oriented ...€¦ · Evangelos Theodoridis CEID - University of Patras Object Oriented Programming II (C++) Fall 2010-2011

� class Screen with a parameter specified for operation displayMessage. This operation requires only a String parameter message that indicates the text to be displayed.

� operation dispenseCash of class CashDispenser takes a Double parameter amount to indicate the amount of cash (in dollars) to be dispensed

� Operation isSufficientCashAvailable also takes � Operation isSufficientCashAvailable also takes a Double parameter amount to indicate the amount of cash in question.


Recommended