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:
+4
-4
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user