Skip to content

Instantly share code, notes, and snippets.

@satojkovic
Created May 30, 2013 16:28
Show Gist options
  • Save satojkovic/5679226 to your computer and use it in GitHub Desktop.
Save satojkovic/5679226 to your computer and use it in GitHub Desktop.
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