Tutorial Sheet 4 1 b )

Hi

My Explaination : As several parts of temple react upon skill level change so State machine , and We could still use observer but its not optimal because of 3 states ,

can this also be correct ?

Hello,

The fact that several parts of the Temple react to the Padawan’s skill-level change is characteristic of the Observer pattern. A State Machine would be about the Padawan transitioning between different states, whereas here the key idea is that one class notifies multiple registered observers. Each observer can then react to the update independently and, depending on the new skill level, change its own attributes or perform its own actions.

Also, having three observers isn’t a reason why the Observer pattern would be non-optimal. Adding new observers without having to modify the Padawan is actually one of the main benefits of the pattern.