def take_loan(user: Customer, amount: float, loan_type: str): """This allows users to take loans according to the type of the loanself. attr: user: An instace of the Customer class loan_type: the type of loan as defined in the LOAN enum. it resolves to a rate""" try: if loan_type in Bank.LOAN.__members__.keys(): print("Your loan is processing, please wait...") loan = Bank.LOAN[ loan_type].value * amount + amount #interest is the first expression. user.balance = user.balance + loan time.sleep(5) today = date.today() print( f"Loan processing successful. amount has been added to your balance as at {today}" ) else: print( "The loan you are applying for is not part of the ones we offer. please check again" ) except TypeError: print("There was an error, please try again later")
def transfer(user: Customer, receiver: Customer, amount: float) -> None: """A method where a user is able to transfer a certain amount to another user both users are instances of the Customer class amount is a float""" try: print("Please wait while your transaction is processing...") time.sleep(5) final = user.transfer(amount) if final > 0: receiver.balance = receiver.balance + final print( f"Transaction successful.N{amount} successfully transferred to {receiver.name}" ) else: print("Transaction not successful") except TypeError: print("An error occured")