Agents-MCP-Hackathon/Python-Code-to-Diagram-Generator-MCP
6
1"""Multiple classes example for testing AST parsing."""2 3class BankAccount:4 """Simple bank account class."""5 6 def __init__(self, account_number, initial_balance=0):7 self.account_number = account_number8 self.balance = initial_balance9 self.transaction_history = []10 11 def deposit(self, amount):12 self.balance += amount13 self.transaction_history.append(f"Deposit: +{amount}")14 15 def withdraw(self, amount):16 if amount <= self.balance:17 self.balance -= amount18 self.transaction_history.append(f"Withdrawal: -{amount}")19 return True20 return False21 22 def get_balance(self):23 return self.balance24 25 26class Customer:27 """Customer class to hold account information."""28 29 def __init__(self, customer_id, name, email):30 self.customer_id = customer_id31 self.name = name32 self.email = email33 self.accounts = []34 35 def add_account(self, account):36 self.accounts.append(account)37 38 def get_total_balance(self):39 return sum(account.get_balance() for account in self.accounts)40 41 42class Bank:43 """Bank class to manage customers and accounts."""44 45 def __init__(self, name):46 self.name = name47 self.customers = {}48 self.next_account_number = 100049 50 def create_customer(self, name, email):51 customer_id = len(self.customers) + 152 customer = Customer(customer_id, name, email)53 self.customers[customer_id] = customer54 return customer55 56 def create_account(self, customer_id, initial_balance=0):57 if customer_id in self.customers:58 account = BankAccount(self.next_account_number, initial_balance)59 self.customers[customer_id].add_account(account)60 self.next_account_number += 161 return account62 return None63 