#################################################################### #Institute : Mahindra Ecole Centrale # #Subject : CS101-Introduction to computer programming, Lab-14 # #Author : Vipin.K # #Description : The bank module declaring the required classes # #################################################################### """ The bank module declaring the required classes for the banking software """ class customer(): """The customer class.\n Initialisation values : customer name, date of birth, address. Wrapper functions can be written for the account class inside. Presently just creates a list of account objects to store the accounts linked to the customer """ def __init__(self, name=None, dob=None, address=None): self.name = name self.dob = dob self.address = address self.accounts = {} #List to store the customer accounts def change_address(self, new_address): """Function to change customer address\n inputs : new address\n outputs : None""" self.address = new_address def add_account(self, new_account_num,init_deposite): """Function to add a new account to a customer\n inputs : account number, initial deposite\n outputs: None\n Creates a new account type object and adds to the accounts dictionary. Dictionary key is the account number and value is the account object """ self.accounts[new_account_num] = account(new_account_num,init_deposite) def remove_account(self, old_account): """Function to delete an existing account of a customer\n inputs : account number\n outputs: None\n Whether account exists or not is assumed to be verified by an upper module """ del self.accounts[old_account] class account(): """The account class.\n Initialisation values : account number and initial deposite. interest rate is declared as a class attribute so that changing its value is reflected in every object. """ int_rate = 0.09 def __init__(self,account_number, init_deposite): self.accnt_num = account_number self.balance = init_deposite def deposit(self, amount): """Function to deposit money to an account\n inputs : deposit amount\n outputs: Balance after deposit\n """ self.balance += amount return self.balance def withdraw(self, amount): """Function to withdraw money from an account\n inputs : withdraw amount\n outputs: Balance after withdrawal\n """ self.balance -= amount return self.balance def calc_interest(self): """Function to calculate half yearly interest\n inputs : None\n outputs: Balance and interest\n """ i = self.balance*self.int_rate*0.5 #Please note here self is required to access the class #attribute also here. directly using int_rate will give #an error. Otherwise should declare it as global. self.balance += i return (i,self.balance) #Tuple to return two values if __name__ == '__main__': #Just print the doc string if executed as the top module print __doc__