Esempio n. 1
0
class RubberDuck(Quackable):
    def __init__(self):
        self.observable = Observable(self)

    def quack(self):
        print "Squeak!"
        self.notifyObservers()

    def registerObserver(self, observer):
        self.observable.registerObserver(observer)

    def notifyObservers(self):
        self.observable.notifyObservers()

    def __str__(self):
        return "Rubber Duck"
Esempio n. 2
0
class MallardDuck(Quackable):
    def __init__(self):
        self.observable = Observable(self)

    def quack(self):
        print "Quack!"
        self.notifyObservers()

    def registerObserver(self, observer):
        self.observable.registerObserver(observer)

    def notifyObservers(self):
        self.observable.notifyObservers()

    def __str__(self):
        return "Mallard Duck"