200 likes | 396 Views
OOAD. An Example. Account. acct # balance sec-code state. Trans_Rec. trans_type date_time amount teller_ID. has . withdrw dep prov_balance. 0..*. 1. Atm. atm #. req_withdrw req_dep req_balance req_int_rate. Std_Acct. Savings_Acct. int_rate. add_on_interest
E N D
OOAD An Example
Account acct # balance sec-code state Trans_Rec trans_type date_time amount teller_ID has withdrw dep prov_balance 0..* 1 Atm atm # req_withdrw req_dep req_balance req_int_rate Std_Acct Savings_Acct int_rate add_on_interest prov_int_rate abstract (Static) Class diagram
ACCOUNT Static OOAD Diagram – other notations acct # balance sec-code state TRANS_REC trans_type date_time amount teller_ID has withdrw dep prov_balance (0,N) (1,1) ATM atm # req_withdrw req_dep req_balance req_int_rate STD_ACCT SAVINGS_ACCT int_rate add_on_interest prov_int_rate
Scenario 1 ACCOUNT abstract acct # balance sec-code state TRANS_REC trans_type date-time amount teller_ID withdrw dep ATM atm # req_withdrw req_dep withdrw / deposit create
Scenario 2 ACCOUNT abstract acct # balance sec-code state prov_balance ATM req_balance prov_balance
ACCOUNT abstract Scenario 3 acct # sec-code state ATM req_int_rate SAVINGS_ACCT int_rate prov_int_rate prov_int_rate
OBJECT SPECIFICATION atm STRUCTURES EXTERNAL INPUTS / OUTPUTS INPUT request-for-withdrawal (atm #, acct #, amount, sec-code) INPUT request-for-deposit (atm #, acct #, amount) INPUT request-for-balance (acct #, sec-code) INPUT request-for-int-rate (acct #, sec-code) OUTPUT message-for-customer OUTPUT cash ATTRIBUTES atm # := identifies atm STATE-DIAGRAM
SERVICES <atm> - SERVICE req_withdrw ( ) VARIABLE ok:= withdrawal possible? TRIGGERED BY INPUT request-for-withdrawal SEND MESSAGE TO account(acct #).withdrw (IN atm #, amount, sec-code; OUT ok) IF ok equal TRUE THEN BEGIN WRITE OUTPUT message-for-customer USE OUPUT cash(amount) END ELSE WRITE OUTPUT message-for-customer END-SERVICE req_withdrw.
SERVICES <atm> - SERVICE req_dep ( ) VARIABLE ok:= deposit successful ? TRIGGERED BY INPUT request-for-deposit SEND MESSAGE TO account(acct #).dep (IN atm #, amount; OUT ok) IF ok equal TRUE THEN WRITE OUTPUT message-for-customer ELSE WRITE OUTPUT message-for-customer END-SERVICE req_dep.
SERVICES <atm> SERVICE req_balance( ) VARIABLE ok:= access to balance possible? TRIGGERED BY INPUT request-for-balance SEND MESSAGE TO account(acct #).prov_balance (IN sec-code; OUT balance, ok) IF ok equal TRUE THEN WRITE OUTPUT message-for-customer (balance) ELSE WRITE OUTPUT message-for-customer END-SERVICE req_balance.
SERVICES <atm> SERVICE req_int_rate( ) VARIABLE ok:= access to int-rate possible? TRIGGERED BY INPUT request-for-int-rate SEND MESSAGE TO savings_acct(acct #).prov_int_rate (IN sec-code; OUT int-rate, ok) IF ok equal TRUE THEN WRITE OUTPUT message-for-customer (int-rate) ELSE WRITE OUTPUT message-for-customer END-SERVICE req_int_rate. END SPECIFICATION atm.
OBJECT SPECIFICATION account STRUCTURES account has (0,N) trans_rec account specialized_into std_acct account specialized_into savings_acct EXTERNAL INPUTS / OUTPUTS ATTRIBUTES acct # := identifies atm balance := current balance on account in $ sec-code := authorization code state := active, closed STATE-DIAGRAM active Informal closed
SERVICES <account> - SERVICE withdrw ( IN atm #, amount, req-sec-code; OUT ok) IF (state = active) & (req-sec-code = sec-code) & (amount < balance) THEN BEGIN <transaction ok> ok <= TRUE balance <= balance - amount SEND MESSAGE TO trans-rec.create (IN “withdrawal”, current date&time, amount, atm #; OUT) END ELSE ok<= FALSE END-SERVICE withdrw.
SERVICES <account> - SERVICE dep ( IN atm #, amount; OUT ok) IF (state = active) THEN BEGIN <transaction ok> ok <= TRUE balance <= balance + amount SEND MESSAGE TO trans-rec.create (IN “depositl”, current date&time, amount, atm #; OUT) END ELSE ok<= FALSE END-SERVICE dep.
SERVICES <account> - SERVICE prov_balance ( IN req-sec-code; OUT result_balance, ok) IF (state = active) & (req-sec-code = sec-code) THEN BEGIN <transaction ok> ok <= TRUE result_balance <= balance END ELSE ok<= FALSE END-SERVICE prov_balance. END SPECIFICATION account.
OBJECT SPECIFICATION std_acct STRUCTURES std_acct is-a account EXTERNAL INPUTS / OUTPUTS ATTRIBUTES STATE-DIAGRAM SERVICES END SPECIFICATION std_acct
OBJECT SPECIFICATION savings_acct STRUCTURES savings_acct is-a account EXTERNAL INPUTS / OUTPUTS ATTRIBUTES int_rate := currently valid interest rate STATE-DIAGRAM
SERVICES <savings_acct> - SERVICE prov_int_rate ( IN req-sec-code; OUT result_int_rate, ok) IF (state = active) & (req-sec-code = sec-code) THEN BEGIN <transaction ok> ok <= TRUE result_int_rate <= int_rate END ELSE ok<= FALSE END-SERVICE prov_int_rate.
SERVICES <savings_acct> - SERVICE add_on_interest ( ) VARIABLE interest := used to calculate interest TRIGGERED BY TIME (end-of-month) calculate interest from ( balance & int-rate ) balance <= balance + interest END-SERVICE add_on_interest. END SPECIFICATION savings_acct.
OBJECT SPECIFICATION trans_rec STRUCTURES trans_rec has <belongs to> (1,1) account EXTERNAL INPUTS / OUTPUTS ATTRIBUTES trans_type := withdrawal or desposit date_time := date & time of transaction amount := amount used in trans_type teller_ID := ID of accessing entity (teller, atm) STATE-DIAGRAM SERVICES - SERVICE create is standard create. END SPECIFICATION trans_rec.