Created
June 26, 2017 15:02
-
-
Save infinite-Joy/7fcb1f90bb23109784ba33453968a232 to your computer and use it in GitHub Desktop.
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 Banking(object): | |
""" Payment processor that does nothing, just logs """ | |
def __init__(self): | |
self._logger = logging.getLogger(__name__) | |
self._logger.setLevel(logging.INFO) | |
def process_payment(self, destination_address, amount): | |
""" Execute a payment to one receiving single address | |
return the transaction id or None """ | |
raise NotImplementedError("Not implemented yet") | |
class BankingBank1(Banking): | |
"""docstring for BankingBank1""" | |
def __init__(self, arg): | |
super(BankingBank1, self).__init__() | |
self.arg = arg | |
def process_payment(self, destination_address, amount): | |
""" Execute a payment to one receiving single address | |
return the transaction id or None """ | |
print('process payment for bank 1') | |
class BankingBank2(Banking): | |
"""docstring for BankingBank1""" | |
def __init__(self, arg): | |
super(BankingBank2, self).__init__() | |
self.arg = arg | |
def user_action(bb_obj): | |
if isinstance(bb_obj, BankingBank1): | |
bb_obj.process_payment('destination_address', 100) | |
elif isinstance(bb_obj, BankingBank2): | |
print('Cannot process the payment.') | |
else: | |
print('implement this.') | |
bb2 = BankingBank2(__name__) | |
user_action(bb2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment