Advertisement
Guest User

Untitled

a guest
May 28th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. class BankAccount:
  2. """ Class definition modeling the behavior of a simple bank account """
  3. balance = 0
  4.  
  5. def __init__(self, balance):
  6. """Creates an account with the given balance."""
  7.  
  8. def deposit(self, amount):
  9. """Deposits the amount into the account."""
  10.  
  11. return balance + amount
  12.  
  13. def withdraw(self, amount):
  14. """
  15. Withdraws the amount from the account. Each withdrawal resulting in a
  16. negative balance also deducts a penalty fee of 5 dollars from the balance.
  17. """
  18.  
  19. fees_paid = 0
  20. if balance > amount:
  21. return balance - amount
  22. else:
  23. return balance - amount - 5
  24. fees_paid = feed_paid + 5
  25.  
  26. def get_balance(self):
  27. """Returns the current balance in the account."""
  28.  
  29. return balance
  30.  
  31. def get_fees(self):
  32. """Returns the total fees ever deducted from the account."""
  33.  
  34. return fees_paid
  35.  
  36. my_account = BankAccount(10)
  37. my_account.withdraw(15)
  38. my_account.deposit(20)
  39. print my_account.get_balance(), my_account.get_fees()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement