📄 templatemethod.py
字号:
#: c03:TemplateMethod.py
# Simple demonstration of Template Method.
class ApplicationFramework:
def __init__(self):
self.__templateMethod()
def __templateMethod(self):
for i in range(5):
self.customize1()
self.customize2()
# Create a "application":
class MyApp(ApplicationFramework):
def customize1(self):
print "Nudge, nudge, wink, wink! ",
def customize2(self):
print "Say no more, Say no more!"
MyApp()
#<hr>
output = '''
Nudge, nudge, wink, wink! Say no more, Say no more!
Nudge, nudge, wink, wink! Say no more, Say no more!
Nudge, nudge, wink, wink! Say no more, Say no more!
Nudge, nudge, wink, wink! Say no more, Say no more!
Nudge, nudge, wink, wink! Say no more, Say no more!
'''
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -