-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
33 lines (26 loc) · 1.12 KB
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from bank_account import BankAccount
class Admin:
def __init__(self):
self.user_accounts = []
def create_account(self, name, email, address, account_type):
account = BankAccount(name, email, address, account_type)
self.user_accounts.append(account)
return account
def delete_account(self, account):
if account in self.user_accounts:
self.user_accounts.remove(account)
return "Account deleted successfully."
else:
return "Account not found."
def list_accounts(self):
return self.user_accounts
def total_balance(self):
total_balance = sum(account.balance for account in self.user_accounts)
return f"Total balance : Rs{total_balance}"
def total_loan_amount(self):
total_loan = sum(account.loan_taken for account in self.user_accounts)
return f"Total loan amount : Rs{total_loan}"
def toggle_loan_feature(self, enable=True):
for account in self.user_accounts:
account.loan_limit = 2 if enable else 0
return "Loan feature enabled" if enable else "Loan feature disabled"