Last active
April 25, 2017 12:45
-
-
Save pmutua/01b8089fb0c18338fd5ba35766ada932 to your computer and use it in GitHub Desktop.
BankAccount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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