91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

精通Python設計模式 高清完整.pdf版+源碼 下載

資源截圖

代碼片段和文件信息

class?Frog:

????def?__init__(self?name):
????????self.name?=?name

????def?__str__(self):
????????return?self.name

????def?interact_with(self?obstacle):
????????print(‘{}?the?Frog?encounters?{}?and?{}!‘.format(self
?????????????????????????????????????????????????????????obstacle?obstacle.action()))


class?Bug:

????def?__str__(self):
????????return?‘a?bug‘

????def?action(self):
????????return?‘eats?it‘


class?FrogWorld:

????def?__init__(self?name):
????????print(self)
????????self.player_name?=?name

????def?__str__(self):
????????return?‘\n\n\t------?Frog?World?———‘

????def?make_character(self):
????????return?Frog(self.player_name)

????def?make_obstacle(self):
????????return?Bug()


class?Wizard:

????def?__init__(self?name):
????????self.name?=?name

????def?__str__(self):
????????return?self.name

????def?interact_with(self?obstacle):
????????print(‘{}?the?Wizard?battles?against?{}?and?{}!‘.format(self?obstacle?obstacle.action()))


class?Ork:

????def?__str__(self):
????????return?‘an?evil?ork‘

????def?action(self):
????????return?‘kills?it‘


class?WizardWorld:

????def?__init__(self?name):
????????print(self)
????????self.player_name?=?name

????def?__str__(self):
????????return?‘\n\n\t------?Wizard?World?———‘

????def?make_character(self):
????????return?Wizard(self.player_name)

????def?make_obstacle(self):
????????return?Ork()


class?GameEnvironment:

????def?__init__(self?factory):
????????self.hero?=?factory.make_character()
????????self.obstacle?=?factory.make_obstacle()

????def?play(self):
????????self.hero.interact_with(self.obstacle)


def?validate_age(name):
????try:
????????age?=?input(‘Welcome?{}.?How?old?are?you??‘.format(name))
????????age?=?int(age)
????except?ValueError?as?err:
????????print(“Age?{}?is?invalid?please?try?\
????????again…“.format(age))
????????return?(False?age)
????return?(True?age)


def?main():
????name?=?input(“Hello.?What‘s?your?name??“)
????valid_input?=?False
????while?not?valid_input:
????????valid_input?age?=?validate_age(name)
????game?=?FrogWorld?if?age?????environment?=?GameEnvironment(game(name))
????environment.play()

if?__name__?==?‘__main__‘:
????main()

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????.......??????2209??2016-03-18?18:41??mpdp-code-master\chapter1\abstract_factory.py

????.......??????2895??2016-03-18?18:41??mpdp-code-master\chapter1\data\donut.json

????.......??????1464??2016-03-18?18:41??mpdp-code-master\chapter1\data\person.xml

????.......??????1952??2016-03-18?18:41??mpdp-code-master\chapter1\factory_method.py

????.......???????121??2016-03-18?18:41??mpdp-code-master\chapter1\id.py

????.......??????1398??2016-03-18?18:41??mpdp-code-master\chapter10\chain.py

????.......??????1778??2016-03-18?18:41??mpdp-code-master\chapter11\command.py

????.......??????1671??2016-03-18?18:41??mpdp-code-master\chapter11\first-class.py

????.......??????4723??2016-03-18?18:41??mpdp-code-master\chapter12\interpreter.py

????.......??????1954??2016-03-18?18:41??mpdp-code-master\chapter13\observer.py

????.......??????2733??2016-03-18?18:41??mpdp-code-master\chapter14\state.py

????.......???????524??2016-03-18?18:41??mpdp-code-master\chapter15\langs.py

????.......??????1439??2016-03-18?18:41??mpdp-code-master\chapter15\strategy.py

????.......??????1925??2016-03-18?18:41??mpdp-code-master\chapter16\graph.py

????.......??????1689??2016-03-18?18:41??mpdp-code-master\chapter16\graph_template.py

????.......??????1847??2016-03-18?18:41??mpdp-code-master\chapter16\graph_template_slower.py

????.......???????570??2016-03-18?18:41??mpdp-code-master\chapter16\template.py

????.......???????831??2016-03-18?18:41??mpdp-code-master\chapter2\apple-factory.py

????.......??????4485??2016-03-18?18:41??mpdp-code-master\chapter2\builder.py

????.......???????871??2016-03-18?18:41??mpdp-code-master\chapter2\builder2.py

????.......??????1420??2016-03-18?18:41??mpdp-code-master\chapter2\computer-builder.py

????.......???????396??2016-03-18?18:41??mpdp-code-master\chapter3\clone.py

????.......??????1829??2016-03-18?18:41??mpdp-code-master\chapter3\prototype.py

????.......???????775??2016-03-18?18:41??mpdp-code-master\chapter4\adapter.py

????.......???????414??2016-03-18?18:41??mpdp-code-master\chapter4\external.py

????.......??????1096??2016-03-18?18:41??mpdp-code-master\chapter5\mymath.py

????.......??????2600??2016-03-18?18:41??mpdp-code-master\chapter6\facade.py

????.......??????1789??2016-03-18?18:41??mpdp-code-master\chapter7\flyweight.py

????.......??????1371??2016-03-18?18:41??mpdp-code-master\chapter8\mvc.py

????.......???????993??2016-03-18?18:41??mpdp-code-master\chapter9\lazy.py

............此處省略23個文件信息

評論

共有 條評論