usingAccount: obj
aClerk: obj
handle:
newBalance := account_1010.deposit(100)
-"-
account_1010: obj
-"-
deposit(amount: var float):
--> balance := balance + amount
-"-
aClerk.handle
Generation of objects – OLD – SKIP
Jeg lavede først denne her udgave men lavede så den ovenfor, som jeg synes er bedre. Så skip dette her afsnit.
In the next snapshots, we show the generation of the objects in the diagram.
- First
usingAccount
is generated frommain
. - Then clerk is generated from
usingAccount
; clerk is is declared usingobj
, which means that its is generated as part of the generation ofusingAccount
. - Then generation of clerk returns to
usingAccount
– the dotted arrow represents a return to the caller. - The account_1010 is generated from
usingAccount
followed by a return tousingAccount
- Finally the generation of
usingAccount
returns tomain
and generation ofusingAccount
with local objectsclerk
andaccount_1010
is completed.
Snapshot after main
has generated usingAccount
.
Snapshot after usingAccount
has generated clerk
.
Snapshot after return of generation of clerk
.
Snapshot after usingAccount
has generated account_1010
.
Snapshot after return of generation of account_1010
.
Snapshot after return of generation of usingAccount
.
Execution of statements -OLD
The next snapshots shows how the execution of statements in usingAccount
takes place. As mentioned before, the line with arrow with no method from main
to usingAccount
illustrates execution of the statements in usingAccount
. The snapshot is before invocation of clerk.handle
.
The next snapshot show how execution of handle takes place. First account.deposit
is invoked followed by yet another deposit
; invocation of addInterest
; invocation of withdraw
and finally invocation of print
.
Start of execution of statements in usingAccount
; before aClerk.handle
.
Snapshot when clerk.handle
has been invoiced; before first statement in handle
.
Snapshot when account_1010.deposit
has been invoked.
One more deposit
Return from deposit
.
Invocation of addInterest
.
Return from addInterest
.
Invocation of withdraw
.
Return from withdraw
.
Invocation of print
Return from print
Return from handle.