Esempio n. 1
0
import sys
from factory import Factory


if __name__ == "__main__":
    if len(sys.argv)==1:
        sys.exit()

    factory = Factory.getFactory(sys.argv[1])

    asahi = factory.createLink("asahi newspaper", "http://wwww.asahi.com")
    yomiuri = factory.createLink("yomiuri newspaper", "http://wwww.yomiuri.co.jp")
    us_yahoo = factory.createLink("Yahoo!", "http://wwww.yahoo.com")

    jp_yahoo = factory.createLink("Yahoo!Japan", "http://wwww.yahoo.co.jp")
    excite = factory.createLink("Excite", "http://wwww.excite.com")
    google = factory.createLink("Google", "http://wwww.google.com")

    tray_news = factory.createTray("Newspaper")
    tray_news.add(asahi)
    tray_news.add(yomiuri)

    tray_yahoo = factory.createTray("Yahoo!")
    tray_yahoo.add(us_yahoo)
    tray_yahoo.add(jp_yahoo)

    tray_search = factory.createTray("Search engine")
    tray_search.add(tray_yahoo)
    tray_search.add(excite)
    tray_search.add(google)
Esempio n. 2
0
# -*- coding: utf-8 -*-

#オブジェクトの生成だけを受け持つクラスを作成し、
#動的にオブジェクトを生成する
#生成されるオブジェクトは共通のAPIをもつ

from factory import Factory
import factory.list

import sys
if __name__ == '__main__':
    factory = Factory.getFactory('factory.list.ListFactory')
    asahi = factory.createLink("朝日新聞", "http://www.asahi.com/")
    yomiuri = factory.createLink("読売新聞", "http://www.yomiuri.co.jp/")
    us_yahoo = factory.createLink("Yahoo!", "http://www.yahoo.com/")
    jp_yahoo = factory.createLink("Yahoo!Japan", "http://www.yahoo.co.jp/")
    excite = factory.createLink("Exite", "http://www.excite.com/")
    google = factory.createLink("Google", "http://www.google.com/")

    traynews = factory.createTray("新聞")
    traynews.add(asahi)
    traynews.add(yomiuri)

    trayyahoo = factory.createTray("Yahoo!")
    trayyahoo.add(us_yahoo)
    trayyahoo.add(jp_yahoo)

    traysearch = factory.createTray("サーチエンジン")
    traysearch.add(trayyahoo)
    traysearch.add(excite)
    traysearch.add(google)