# BankDatabase is a module that holds the bank's accounts
#  and functions that maintain the accounts

# The database is a list (for now...)
# Let's pretend there are three accounts:

database = [2000, 5050, 500]

# We maintain the balances in cents; all accounts must have
#     non-negative balances !
# The accounts are numbered by 0,1,2


def withdraw(account, amount) :
    """withdraw tries to withdraw money from a bank account

       parameters: account - the account number, an int
                   amount - how much to withdraw
       returns: the money withdrawn
    """
    money = 0
    if (account >= 0) and (account < len(database)) :
        balance = database[account]
        if amount > balance :   # oops -- balance too small ?
            money = balance
        else :
            money = amount
        database[account] = database[account] - money
    return money


# There will also be functions that 
#   --- make a deposit to an existing account
#   --- check the balance of an existing account
#   --- open a new account
#   --- close an existing account
#   ...
    