Skip to content

Instantly share code, notes, and snippets.

@satojkovic
Created May 30, 2013 16:28
Show Gist options
  • Save satojkovic/5679232 to your computer and use it in GitHub Desktop.
Save satojkovic/5679232 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
class Print(object):
def print_weak(self):
pass
def print_strong(self):
pass
# Adaptor(delegation)
class PrintBanner(Print):
def __init__(self, text):
self.banner = Banner(text)
def print_weak(self):
self.banner.show_with_paren()
def print_strong(self):
self.banner.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