# Jared Wasserman
# 5/19/2013
# Python translation of Arup's BankAccount class

class BankAccount:
    # name stores bank account owner's name
    # savings stores savings balance
    # checking stores checking balance
    # interestrate stores interest rate as a decimal
    
    # Creates Bank Account object based on parameters passed to the method.
    def __init__ (self, n="JohnDoe", sav=0, check=0, ir=0.05):
        self.name = n
        self.savings = sav
        self.checking = check
        self.interestrate = ir

    # Withdraws the amount of the parameter from checking account. Next three
    # methods work similarly, either withdrawing or depositing from the
    # checking or savings account.
    def withdraw_chk(self, amount_sub):
        self.checking -= amount_sub
    
    def deposit_chk(self, amount_add):
        self.checking += amount_add
    
    def withdraw_sav(self, amount_sub):
        self.savings -= amount_sub
    
    def deposit_sav(self, amount_add):
        self.savings += amount_add

    # Return's money in savings account.
    def getSavings(self):
        return self.savings 

    # Return's money in checking account.
    def getChecking(self):
        return self.checking 

    # Returns the interest rate
    def getIrate(self):
        return self.interestrate

    # Changes the interest rate to parameter passed to the method.
    def changeRate(self, rate):
        self.interestrate = rate 
    
    # Matures the account 1 year based on current savings and interest rate.
    def matureAccount(self):
        self.savings = self.savings * (1 + self.interestrate)

    # Merges two accounts. The account passed in as a parameter is "added"
    # to the account the method is called on. This simply means transferring
    # the savings and checking balances from the account passed in as a
    # parameter. Then this account is zeroed out. The interest rate is the
    # maximum of the two accounts.
    def mergeAccount(self, account1):
        self.savings += account1.savings
        account1.savings = 0 
        self.checking += account1.checking 
        account1.checking = 0 
        if (account1.interestrate > self.interestrate):
            self.interestrate = account1.interestrate

    # Returns true if its okay to write a check of the amount passed in as a
    # parameter.
    def noBounce(self, check):
        return (check <= self.checking) 

    # Returns true if its okay to take amount amount of money from savings
    # account.
    def drawSavings(self, amount):
        return (amount <= self.savings)

    # Returns the total money stored in the BankAccount object.
    def totalMoney(self):
        return self.savings + self.checking

    # Prints all account information.
    def printInfo(self):
        print("Account Information")
        print("-------------------") 
        print("Name : " + self.name) 
        print("Savings Balance : $" + str(self.savings)) 
        print("Checking Balance : $" + str(self.checking)) 
        print("Interest Rate : " + str(100 * self.interestrate) + "%")
