Skip to content

Instantly share code, notes, and snippets.

@ooade
Created September 5, 2016 13:18
Show Gist options
  • Save ooade/e1e52b477f310d7b5aad2a3284199279 to your computer and use it in GitHub Desktop.
Save ooade/e1e52b477f310d7b5aad2a3284199279 to your computer and use it in GitHub Desktop.
Bank Account
class BankAccount():
def withdraw():
pass
def deposit():
pass
class SavingsAccount(BankAccount):
def __init__(self):
self.balance = 500
def deposit(self, amount):
if amount < 1:
return "Invalid deposit amount"
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 1:
return "Invalid withdraw amount"
if amount > self.balance:
return "Cannot withdraw beyond the current account balance"
if self.balance - amount < 500:
return "Cannot withdraw beyond the minimum account balance"
self.balance -= amount
return self.balance
class CurrentAccount(BankAccount):
def __init__(self):
self.balance = 0
def deposit(self, amount):
if amount < 1:
return "Invalid deposit amount"
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 1:
return "Invalid withdraw amount"
if amount > self.balance:
return "Cannot withdraw beyond the current account balance"
self.balance -= amount
return self.balance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment