Created
May 30, 2013 16:28
-
-
Save satojkovic/5679226 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
import os | |
# Given | |
class Banner(object): | |
def __init__(self, text): | |
self.text = text | |
def show_with_paren(self): | |
print '(%s)' % self.text | |
def show_with_aster(self): | |
print '*%s*' % self.text | |
# Adaptor(inheritance) | |
class PrintBanner(Banner): | |
def __init__(self, text): | |
super(PrintBanner, self).__init__(text) | |
def print_weak(self): | |
self.show_with_paren() | |
def print_strong(self): | |
self.show_with_aster() | |
def main(): | |
p = PrintBanner("Hello") | |
p.print_weak() | |
p.print_strong() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment