2008-07-31から1日間の記事一覧
C# Design Patterns 31. The Visitor Pattern.
class Boss(Employee): # Visitor::ConcreteElement def __init__(self, name, salary, vdays, sdays, bonusDays=None): Employee.__init__(self, name, salary, vdays, sdays) self.bonusDays = bonusDays def accept(self, v): source = "v.visit_%s(self)…
class Employee: # Visitor::ConcreteElement def __init__(self, name, salary, vDays, sDays): self.name = name self.salary = salary self.sickDays = sDays self.vacDays = vDays def accept(self, v): source = "v.visit_%s(self)"%self.__class__.__n…
WPF アプリケーションとして、IronPython で実現した事例を紹介します。 # -*- coding: utf-8 -*- #=============================================================================== # Copyright (C) 2000-2008, 小泉ひよ子とタマゴ倶楽部 # # History: D…
if __name__ == "__main__": print __file__,"ver.1.1" win = Visitor_WPF() win.Title = win.__class__.__name__ # .Text Application().Run(win) Text に代えて、Title に値を設定しています。
class Visitor_WPF(Window): # Form # Visitor::ObjectStructure Form に代えて、Window を拡張しています。 def __init__(self, **args): self.InitializeComponent() self.init() def init(self): self.empls = # Employee for e in [ Employee("Susan Bea…
class bVacationVisitor(Visitor): # Visitor::ConcreteVisitor def __init__(self): self.totalDays = 0 def visit_Employee(self, emp): # visit(Employee emp) self.totalDays += emp.vacDays def visit_Boss(self, bos): # visit(Boss bos) self.totalDa…
class VacationVisitor(Visitor): # Visitor::ConcreteVisitor def __init__(self): self.totalDays = 0 def visit_Employee(self, emp): # visit(Employee emp) self.totalDays += emp.vacDays def visit_Boss(self, bos): # visit(Boss bos) self.totalDay…
class Visitor: # abstract # Visitor::Visitor def visit_Employee(self, emp): raise NotImplementedError("%s.visit_Employee" %self.__class__.__name__) def visit_Boss(self, bos): raise NotImplementedError("%s.visit_Boss" %self.__class__.__name…
C#.use(better, IronPython="GoF") 《記事一覧》 Visitor〈WPF〉Visitor -- pay a tribute to "C# Design Patterns" by James William Cooper 《著》小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部第2版♪2008/03/21 ● 改訂♪2008/10/25