Created
September 5, 2016 13:18
-
-
Save ooade/e1e52b477f310d7b5aad2a3284199279 to your computer and use it in GitHub Desktop.
Bank Account
This file contains hidden or 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(): | |
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