In this assignment, we will build a simple simulation of Electronic Funds Transfers (EFT) between bank accounts, incorporating a daily limit. This means that only a certain maximum amount can be withdrawn or transferred from an account per day.
Part 2: Bank Transactions (5 points)
List of Accounts (1 point)
Define a list variable accounts_list
where you store BankAccount
objects. Add three accounts to this list, for example:
- Account 1: “NL01BANK0123456789”, 1000.00
- Account 2: “BE68BANK12345678”, 500.00
- Account 3: “NL03BANK1357924680”, 1200.50
Functions (3 points)
- Write a function
transfer_funds
(2 points):
- Parameters:
source_account
(str): the account number of the source.
target_account
(str): the account number of the recipient.
amount
(float): the amount to be transferred.
accounts_list
(list): the list of all BankAccount
objects.
- Behavior:
- Search in the list for both Accounts. If one of the two is not found, return an error message.
- Check if
amount > 0
. If not, return a message (e.g., “Amount must be greater than 0.”).
- Try to withdraw the amount from the source account. If the withdraw operation fails due to insufficient balance, return a message (e.g., “Insufficient funds.”).
- If the withdraw succeeds, perform the deposit. Return a string message indicating that the transfer was successful, for example: “Transfer successful.”
- Write a function
new_day
(1 point):
- Parameters:
accounts_list
(list): the list of all BankAccount
objects.
- Behavior:
- The function will start a new day for all
BankAccount
objects in the list.
Testing (1 point)
Test your two functions using the following scenarios:
- The transaction is carried out correctly between two
BankAccount
s.
- The transaction is not carried out correctly because one of the
BankAccount
s cannot be found.
- The transaction cannot be executed because the daily limit has been exceeded.
- A new day starts for your
BankAccount
s.