7from .observer_class
import ObserverForDecimal, ObserverForHexaDecimal, ObserverForBinary
8from .observersubject_numberproducer
import ObserverSubject_NumberProducer
32 print(
"Observer Exercise")
46 numberProducer.SubscribeToNumberChanged(observerDecimal)
47 numberProducer.SubscribeToNumberChanged(observerHexadecimal)
48 numberProducer.SubscribeToNumberChanged(observerBinary)
53 for index
in range(0, 10):
54 print(
" Update {0} on number producer. Results from observers:".format(index))
55 numberProducer.Update();
59 numberProducer.UnsubscribeFromNumberChanged(observerDecimal)
60 numberProducer.UnsubscribeFromNumberChanged(observerHexadecimal)
61 numberProducer.UnsubscribeFromNumberChanged(observerBinary)
Represents an observer that prints out the current number from the Subject in binary.
Represents an observer that prints out the current number from the Subject in decimal.
Represents an observer that prints out the current number from the Subject in hexadecimal.
Represents the Subject to be observed; in this case, a class that contains a single number that is up...
def Observer_Exercise()
Example of using the Observer Pattern.