コード例 #1
0
def testAccount():
    account = SavingsAccount("Alex", "1000", 500.00)
    print(account)
    print(account.deposit(100))
    print("Expect 600:", account.getBalance())
    print(account.deposit(-50))
    print("Expect 600:", account.getBalance())
    print(account.withdraw(100))
    print("Expect 500:", account.getBalance())
    print(account.withdraw(-50))
    print("Expect 500:", account.getBalance())
    print(account.withdraw(100000))
    print("Expect 500:", account.getBalance())
コード例 #2
0
def testAccount():
    """Test function for savings account."""
    account = SavingsAccount("Ken", "1000", 500.00)
    print(account)
    print(account.deposit(100))
    print("Expect 600:", account.getBalance())
    print(account.deposit(-50))
    print("Expect 600:", account.getBalance())
    print(account.withdraw(100))
    print("Expect 500:", account.getBalance())
    print(account.withdraw(-50))
    print("Expect 500:", account.getBalance())
    print(account.withdraw(100000))
    print("Expect 500:", account.getBalance())
コード例 #3
0
 def withdraw(self, amount):
     if self.counter == \
        RestrictedSavingsAccount.MAX_WITHDRAWALS:
         return "Withdrawls maxed out for month"
     else:
         message = SavingsAccount.withdraw(self, amount)
         if message == None:
             self.counter += 1
         return message
 def withdraw(self, amount):
     """Restricts number of withdrawaks to MAX_WITHDRAWALS."""
     if self.counter == RestrictedSavingsAccount.MAX_WITHDRAWALS:
         return 'No more withdrawals this month'
     else:
         message = SavingsAccount.withdraw(self, amount)
         if message == None:
             self.counter += 1
         return message