本文整理匯總了Python中plan.Plan.merge方法的典型用法代碼示例。如果您正苦於以下問題:Python Plan.merge方法的具體用法?Python Plan.merge怎麽用?Python Plan.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plan.Plan
的用法示例。
在下文中一共展示了Plan.merge方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from plan import Plan [as 別名]
# 或者: from plan.Plan import merge [as 別名]
class Person:
def __init__(self, name, boss_name, score):
self.name = name
self.score = score
self.boss_name = boss_name
self.children = []
self.attending_plan_cache = None
self.not_attending_plan_cache = None
def add_child(self, child):
self.children.append(child)
def attending_plan(self):
if not self.attending_plan_cache:
self.attending_plan_cache = Plan(self, True)
for child in self.children:
self.attending_plan_cache.merge(child.not_attending_plan())
return self.attending_plan_cache
def not_attending_plan(self):
if not self.not_attending_plan_cache:
self.not_attending_plan_cache = Plan(self, False)
for child in self.children:
self.not_attending_plan_cache.merge(child.best_plan())
return self.not_attending_plan_cache
def best_plan(self):
if self.attending_plan().is_better_than(self.not_attending_plan()):
return self.attending_plan()
else:
return self.not_attending_plan()