feat(cmat): implement Ex41 observer pattern

Refactor the Pelican crossing exercise to use the Observer
pattern: Pelican acts as Subject and each Pole observes it,
replacing direct calls through the owned Pole pointer.

Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
This commit is contained in:
2026-10-06 16:26:53 +02:00
co-authored by Qwen 3.8 27B
parent c681ebab2b
commit 6e0e45110a
8 changed files with 39 additions and 28 deletions
+4 -4
View File
@@ -7,12 +7,14 @@
#ifndef PELICAN_H
#define PELICAN_H
#include "Subject.h"
class PelicanTimer;
class Pole;
class Pelican {
class Pelican : public Subject {
public:
Pelican(int x, int y);
Pelican();
~Pelican();
// call when the WAIT button has been pressed
@@ -39,8 +41,6 @@ class Pelican {
// indicates whether the WAIT light should be on
bool pressed;
Pole *myPole;
// Timer that indicates when the lights should change
PelicanTimer *myTimer;