Open abdoatef22-g opened 1 month ago
V +------------------+ | Account | +------------------+ | -accountNumber: | | String | | -balance: Double | +------------------+ | | 1 | V +------------------+ | Transaction | +------------------+ | -transactionID: | | String | | -amount: Double | | -date: Date | +------------------+
`class Bank: def init(self, name, address): self.name = name self.address = address self.customers = []
def add_customer(self, customer): self.customers.append(customer)
def get_customers(self): return self.customers Customer.py python
class Customer: def init(self, name, id): self.name = name self.id = id self.accounts = []
def add_account(self, account): self.accounts.append(account) def get_accounts(self): return self.accounts
Account.py python
class Account: def init(self, account_number, balance): self.account_number = account_number self.balance = balance self.transactions = []
def add_transaction(self, transaction): self.transactions.append(transaction) def get_transactions(self): return self.transactions
Transaction.py python
from datetime import date
class Transaction: def init(self, transaction_id, amount, date): self.transaction_id = transaction_id self.amount = amount self.date = date
def get_transaction_id(self): return self.transaction_id def get_amount(self): return self.amount def get_date(self): return self.date
from Bank import Bank from Customer import Customer from Account import Account from Transaction import Transaction from datetime import date my_bank = Bank("Bank of Python", "123 Python Street")
customer1 = Customer("Alice", "001")
my_bank.add_customer(customer1)
account1 = Account("123456789", 1000.0) customer1.add_account(account1)
transaction1 = Transaction("tx001", 200.0, date.today())
account1.add_transaction(transaction1)
print("Bank Name:", my_bank.name) print("Customer Name:", my_bank.get_customers()[0].name) print("Account Balance:", customer1.get_accounts()[0].balance) print("Transaction Amount:", account1.get_transactions()[0].get_amount())`
+------------------+ 1 * +------------------+
`class Bank: def init(self, name, address): self.name = name self.address = address self.customers = []
def add_customer(self, customer): self.customers.append(customer)
def get_customers(self): return self.customers Customer.py python
class Customer: def init(self, name, id): self.name = name self.id = id self.accounts = []
Account.py python
class Account: def init(self, account_number, balance): self.account_number = account_number self.balance = balance self.transactions = []
Transaction.py python
from datetime import date
class Transaction: def init(self, transaction_id, amount, date): self.transaction_id = transaction_id self.amount = amount self.date = date
from Bank import Bank from Customer import Customer from Account import Account from Transaction import Transaction from datetime import date my_bank = Bank("Bank of Python", "123 Python Street")
customer1 = Customer("Alice", "001")
my_bank.add_customer(customer1)
account1 = Account("123456789", 1000.0) customer1.add_account(account1)
transaction1 = Transaction("tx001", 200.0, date.today())
account1.add_transaction(transaction1)
print("Bank Name:", my_bank.name) print("Customer Name:", my_bank.get_customers()[0].name) print("Account Balance:", customer1.get_accounts()[0].balance) print("Transaction Amount:", account1.get_transactions()[0].get_amount())`