Solution (source code)

= Solution

A generic pull-style <UML class diagram> is shown below. `ConcreteSubject` inherits subscription management from `Subject`; `ConcreteObserver` realizes the `Observer` interface. The subject can have many registered observers, while a concrete observer uses its subject reference to obtain state during `update`.

\Image[/past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/imperative-resit-observer-pattern.png]
{title=Observer-pattern roles, subscriptions and pull-style state access}
{description=Open triangles indicate inheritance or interface realization. Ordinary directed associations indicate references and do not assert ownership of observer lifetimes. Subject notification invokes the Observer update interface.}