from abc import ABC, abstractmethod from behavioral.observer.observer import Observer class Subject(ABC): """ The Subject interface declares a set of methods for managing subscribers. """ @property @abstractmethod def state(self) -> int: pass @abstractmethod def attach(self, observer: Observer) -> None: """ Attach an observer to the subject. """ pass @abstractmethod def detach(self, observer: Observer) -> None: """ Detach an observer to the subject. """ pass @abstractmethod def notify(self) -> None: """ Notify all observers about an event. """ pass