Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. class BankAccount(object):
  2. def withdraw(self):
  3. pass
  4. def deposit(self):
  5. pass
  6.  
  7. class SavingsAccount(BankAccount):
  8. def __init__(self):
  9. self.balance = 500
  10.  
  11. def deposit(self, amount):
  12. if (amount <= 0):
  13. return "Invalid deposit amount"
  14. else:
  15. self.balance =self.balance + amount
  16. return self.balance
  17.  
  18. def withdraw(self, amount):
  19. if ( amount <= 0):
  20. return "Invalid withdrawal amount"
  21. elif (amount >= self.balance ):
  22. return "Cannot withdraw beyond the current account balance"
  23. elif (self.balance - amount <= 500):
  24. return "Cannot withdraw beyond the minimum account balance"
  25. else:
  26. self.balance = self.balance - amount
  27. return self.balance
  28.  
  29. class CurrentAccount(BankAccount):
  30. def __init__(self):
  31. self.balance = 0
  32. def deposit(self, amount):
  33. if (amount <= 0):
  34. return "Invalid deposit amount"
  35. else:
  36. self.balance = self.balance + amount
  37. return self.balance
  38.  
  39. def withdraw(self, amount):
  40. if (amount <= 0):
  41. return "Invalid withdraw amount"
  42. elif (amount >= self.balance ):
  43. return "Cannot withdraw beyond the current account balance"
  44. else:
  45. self.balance = self.balance - amount
  46. return self.balance
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement