Design Pattern Examples
Overview of object-oriented design patterns
ObserverForDecimal Class Reference

Represents an observer that prints out the current number from the Subject in decimal. More...

Inheritance diagram for ObserverForDecimal:
Inheritance graph
Collaboration diagram for ObserverForDecimal:
Collaboration graph

Public Member Functions

 ObserverForDecimal (INumberProducer numberProducer)
 Constructor.
 
void NumberChanged ()
 This is called whenever the number in the ObserverSubject_NumberProducer object is changed.
 

Private Member Functions

void IObserverNumberChanged. NumberChanged ()
 Called whenever the number is changed in the number producer. This observer instance must first be subscribed to the number producer to receive calls on this method.
 

Private Attributes

INumberProducer _numberProducer
 The number producer from which to get the current number.
 

Detailed Description

Represents an observer that prints out the current number from the Subject in decimal.

Definition at line 17 of file Observer_Class.cs.

Constructor & Destructor Documentation

◆ ObserverForDecimal()

ObserverForDecimal ( INumberProducer  numberProducer)
inline

Constructor.

Parameters
numberProducerA number producer as represented by an INumberProducer interface. Cannot be null.

Definition at line 30 of file Observer_Class.cs.

References ObserverForDecimal._numberProducer.

Member Function Documentation

◆ NumberChanged()

void IObserverNumberChanged. NumberChanged ( )
inlineprivate

Called whenever the number is changed in the number producer. This observer instance must first be subscribed to the number producer to receive calls on this method.

In this example, this notification handler prints out the current number in decimal.

Implements IObserverNumberChanged.

Definition at line 48 of file Observer_Class.cs.

References ObserverForDecimal._numberProducer, and INumberProducer.FetchNumber().

Member Data Documentation

◆ _numberProducer

INumberProducer _numberProducer
private

The number producer from which to get the current number.

Definition at line 22 of file Observer_Class.cs.

Referenced by ObserverForDecimal.NumberChanged(), ObserverForHexaDecimal.NumberChanged(), ObserverForBinary.NumberChanged(), and ObserverForDecimal.ObserverForDecimal().


The documentation for this class was generated from the following file: