Download præsentationen
Præsentation er lastning. Vent venligst
Offentliggjort afPer Fog Redigeret for ca. et år siden
1
Automated Teller Machine - (ATM ) Lars Schelde Jens S. Olsen
2
Agenda Funktioner Krav Klassediagram Implementering Test
3
Funktioner Konto administration Indsæt penge Hæve penge Kontrol af korrekt opgørelse I relation til seddel nomination. Saldo kontrol Registrering af bevægelser Overflytte penge til en anden konto
4
Kravene til programmet (1): R1 : En konto består af et navn, et konto nr., en saldo, et overtræks-beløb, en PIN-kode, antal forsøg siden sidste rigtige PIN-kode og om kontoen er spærret. R2 : En konto bliver spærret efter 3 på hinanden følgende fejlindtastninger af PIN-koden. R3 : Administratoren (bankrådgiveren) kan oprette en konto, bevilge et overtræk, ændre størrelsen af et overtræk og ophæve bevillingen af et overtræk. Endvidere kan administratoren spærre og genåbne en konto. R4 : Der kan indsættes penge på en konto, beløb svarende til en sum af de danske pengesedler. Hvis ikke beløbet svarer til en sum af de danske pengesedler, er der kommet falske penge i automaten, og kontoen spærres. R5 : Der kan udbetales et beløb i sedler fra en konto, såfremt der er kontoens saldo + evt. bevilget overtræk er større end det beløb der ønskes hævet og kontoens saldo vil blive nedskrevet med det udbetalte beløb. Hvis det ønskede beløb ikke kan udbetales, grundet beløbet ikke er delelig med de danske pengesedler, afrundes der nedad til nærmeste mulige beløb der kan udbetales med de danske pengesedler. Hvis der ikke kan udbetales penge grundet manglende, udskrives der en besked til brugeren om at kontakte bankrådgiveren med henblik på at få ændret eller oprettet muligheden for overtræk.
5
Kravene til programmet (2): R6: Der kan overføres et beløb fra en konto til en anden, såfremt kontoens saldo + evt. bevilget overtræk er større end det beløb der ønskes overflyttet og kontoens saldo vil herefter blive nedskrevet med det udbetalte beløb. R7: For hver transaktion der laves, registreres datoen, typen af transaktionen Ved udbetaling registreres endvidere beløbet samt saldoen Ved kontooverførsel registreres endvidere beløbet samt saldoen Ved oprettelse/ændring/ophævelse af overtræksbevillingen endvidere størrelsen på den nye overtræksbevilling R8: Der kan laves et kontoudtog, hvor alle transaktionerne vises.
6
1 2 3
8
Date Transaction Bank Account Cash Account AccountDB Environment ATM System World
9
Implementering (1) R1: (konto-data) implementeres i klasserne: BankAccount name : BankAccountNameType number : BankAccountType isopen : bool CashAccount balance: BankAccount`BankAccountMoneyType creditlimit: BankAccount`BankAccountMoneyType pincode: BankAccount`BankAccountPincodeType pincodeerrorcount: nat
10
Implementering (2) R2: (Spærring af konto, 3 pinkode fejl)implementeres i klassen: AccountDB public RequestCheckPin : BankAccount`BankAccountType * BankAccount`BankAccountPincodeType ==> boolRequestCheckPin(accnum, pincode) == ( if accounts(accnum).IsPin(pincode) then ( transactioncode := ; accounts(accnum).AddTransaction(transactioncode); return true;); ) transactioncode := ; accounts(accnum).AddTransaction(transactioncode); if accounts(accnum).getPinErrorCount() = 3 then ( accounts(accnum).setIsOpen(false); transactioncode := ; accounts(accnum).AddTransaction(transactioncode); );return false; ) pre accnum in set dom accounts;
11
Implementering (3) R3: (Administrator rettigheder)implementeres i klasserne: ATM instance variables isadministrator: bool pre isadministrator = true Metoder : AdminCreateAccount, AdminSetLimit, AdminOpenAccount, AdminCloseAccount AccountDB public CreateAccount: BankAccount`BankAccountNameType * BankAccount`BankAccountPincodeType ==> () CreateAccount(name, pin) == ( transactioncode := ; accounts := accounts ++ { nextaccountid |-> new CashAccount(name,nextaccountid,pin,transactioncode) }; nextaccountid := nextaccountid + 1; );
12
Implementering (4) R4: (Indsæt penge) implementeres i klassen: AccountDB instance variables bills: seq of BankAccount`BankAccountMoneyType := [1000,500,200,100,50]; AmountLegal: BankAccount`BankAccountMoneyType ==> BankAccount`BankAccountMoneyTypeAmountLegal(amt) == return amt - amt mod bills(len bills) pre amt >= 0; AmountIsLegalCheck: BankAccount`BankAccountMoneyType ==> bool AmountIsLegalCheck(amt) == return (amt = amt - amt mod bills(len bills)) pre amt >= 0;
13
Implementering (5) R5:(Hæve/Sætte ind) + R6: (Flytte til konto)implementeres i klasserne: AccountDB public RequestTransferAccounts : BankAccount`BankAccountType * BankAccount`BankAccountType * BankAccount`BankAccountMoneyType ==> bool RequestTransferAccounts (sourceaccnum, targetaccnum, amt) ==( if(not accounts(sourceaccnum).getIsOpen()) then ( transactioncode := ; accounts(sourceaccnum).AddTransaction(amt, transactioncode); return false ); if(not accounts(sourceaccnum).RequestWithdrawal(amt)) then ( transactioncode := ; accounts(sourceaccnum).AddTransaction(targetaccnum, amt, transactioncode); return false );
14
Implementering (6) R5:(Hæve/Sætte ind) + R6: (Flytte til konto)implementeres i klasserne: AccountDB Withdraw(sourceaccnum,amt); transactioncode := ; accounts(sourceaccnum).AddTransaction(targetaccnum, amt, transactioncode); Deposit(targetaccnum,amt); transactioncode := ; accounts(targetaccnum).AddTransaction(sourceaccnum, amt, transactioncode); return true ) pre sourceaccnum in set dom accounts and targetaccnum in set dom accounts and amt >= 0;
15
Implementering (7) R5:(Hæve/Sætte ind) + R6: (Flytte til konto)implementeres i klasserne: CashAccount public RequestWithdrawal : BankAccount`BankAccountMoneyType ==> bool RequestWithdrawal (amt) == return (balance + creditlimit > amt) pre getIsOpen();
16
Implementering (8) R7: (transaktionslog) implementeres i klasserne: Transaction types public Code = | | | | | | | | | | | | | | | ; public TransactionType = nat; instance variables balance: BankAccount`BankAccountMoneyType := 0; creditlimit: BankAccount`BankAccountMoneyType := 0; amount: BankAccount`BankAccountMoneyType := 0; accnumother : [BankAccount`BankAccountType] ; name : BankAccount`BankAccountNameType; accnumber : BankAccount`BankAccountType; isopen : bool; transactiontype: Code; -- system call to date...?? now: Date := new Date(26,2,2009);
17
Test Vi har endnu ikke fået VDM++ testene til at køre automatisk, men i ”Intepreteren” Initializing specification... done >> create t:= new Test1() >> print t.Run() 0 >> print t.atm.database
18
Test 1 class Test1 instance variables public atm: ATM := new ATM(); i: nat1 := 1; operations public Run:() ==> nat Run() == ( -- 1 administrator login if not atm.Login(1,0) then return i; i := 2; -- 2 adduser Lars, pincode 1234 then return i; if not atm.AdminCreateAccount("Lars",1234) then return i; ... i := 23; --23 logout if not atm.Logout() then return i; return 0
19
Test 2, Print af transaktioner Initializing specification... done >> create t:= new Test1() >> print t.Run() 0 Construct is fully evaluated >> print t.atm.database objref24(AccountDB): objref25(CashAccount): < BankAccount`isopen = true, BankAccount`name = "Administrator", BankAccount`number = 1, CashAccount`balance = 0, … 2 |-> objref58(Transaction): >, Transaction`accnumother = 2, Transaction`amount = 550, Transaction`balance = 550, Transaction`creditlimit = 0, Transaction`isopen = true, Transaction`name = "Lars", Transaction`now = objref59, Transaction`transactiontype = >
20
Test 3, Print af transaktioner 4 |-> objref74(Transaction): < Transaction`accnumber = 3, Transaction`accnumother = 2, Transaction`amount = 33, Transaction`balance = 467, Transaction`creditlimit = 0, Transaction`isopen = true, Transaction`name = "Jens", Transaction`now = objref75, Transaction`transactiontype = > 4 |-> objref80(Transaction): < Transaction`accnumber = 2, Transaction`accnumother = 3, Transaction`amount = 33, Transaction`balance = 583, Transaction`creditlimit = 0, Transaction`isopen = false, Transaction`name = "Lars", Transaction`now = objref81, Transaction`transactiontype = >
21
Test 4, Print af transaktioner 6 |-> objref92(Transaction): < Transaction`accnumber = 3, Transaction`accnumother = >, Transaction`amount = 0, Transaction`balance = 467, Transaction`creditlimit = 0, Transaction`isopen = true, Transaction`name = "Jens", Transaction`now = objref93, Transaction`transactiontype = > 9 |-> objref110(Transaction): < Transaction`accnumber = 3, Transaction`accnumother = >, Transaction`amount = 0, Transaction`balance = 467, Transaction`creditlimit = 0, Transaction`isopen = false, Transaction`name = "Jens", Transaction`now = objref111, Transaction`transactiontype = >
22
Test 5, Print af transaktioner 3 |-> objref50(Transaction): < Transaction`accnumber = 2, Transaction`accnumother = >, Transaction`amount = 55, Transaction`balance = 550, Transaction`creditlimit = 0, Transaction`isopen = false, Transaction`name = "Lars", Transaction`now = objref51, Transaction`transactiontype = > 10 |-> objref122(Transaction): < Transaction`accnumber = 3, Transaction`accnumother = >, Transaction`amount = 0, Transaction`balance = 467, Transaction`creditlimit = 0, Transaction`isopen = true, Transaction`name = "Jens", Transaction`now = objref123, Transaction`transactiontype = >,
Lignende præsentationer
© 2024 SlidePlayer.dk Inc.
All rights reserved.