Advertisement
Guest User

Untitled

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