Skip to content

Instantly share code, notes, and snippets.

@pmutua
Last active April 25, 2017 12:45
Show Gist options
  • Save pmutua/01b8089fb0c18338fd5ba35766ada932 to your computer and use it in GitHub Desktop.
Save pmutua/01b8089fb0c18338fd5ba35766ada932 to your computer and use it in GitHub Desktop.
BankAccount
class BankAccount:
def withdraw(self):
return
def deposit(self):
return
class SavingsAccount(BankAccount):
balance = float(0);
def __init__(self):
self.balance = 500
def deposit(self, amount):
if amount < 0:
return "Invalid deposit amount"
self.balance += amount
return self.balance
def withdraw(self, 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"
if amount < 0:
return "Invalid withdraw amount"
self.balance -= amount
return self.balance
class CurrentAccount(BankAccount):
balance = float(0);
def __init__(self):
balance = 0;
def deposit(self, amount):
if amount < 0:
return "Invalid deposit amount"
self.balance += amount
return self.balance
def withdraw(self, amount):
if (self.balance-amount) < 0:
return "Cannot withdraw beyond the current account balance"
if amount < 0:
return "Invalid withdraw amount"
self.balance -= amount
return self.balance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment