M206 - TMA01 Question 4
(i)a) To create account1 and account2 1 used the following message statements;
Firstly create account1 and account2 using the Create Account Button.
- account1holder: 'Jennie Lee'
- account1overLimit: 400
- account1balance: 500 account2 holder: 'Martin Cruz'
- account2 overLimit.. 300
- account2 balance: 400
b) It is possible to confirm at these two accounts have had their attributes correctly set by sending a message to an attribute and then reading the message answer. The message account1holder causes the message answer 'Jennie Lee' , this would have to be repeated for overLimit and balance for both accounts and holder for account2.
ii)a) A message expression to deduct 950 from account1is:- account1 debit: 950. The message answer false is produced because the overLimit of account1has been exceeded. 500 - 950 = -450 this would be 50 below the overLimit which not possible hence the message answer false.
b) A message expression to deduct 500 from account2 is:- account2 debit: 500. The message answer is true because the account now has a balance of -100, but the overLimit of 300 has not been exceeded. The state of account 2 is now holder 'Martin Cruz' overLimit 300 and balance -100.
c) A message expression to transfer 200 from account1 to account2 follows:
account1 transfer: 200 to: account2
Object -interaction diagram for account1 transfer: 200 to: account2