mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
28 lines
692 B
Python
28 lines
692 B
Python
from abc import ABC, abstractmethod
|
|
|
|
from behavioral.state.context import Context
|
|
|
|
|
|
class State(ABC):
|
|
"""
|
|
The base State class declares methods that all Concrete State should
|
|
implement and also provides a backreference to the Context object,
|
|
associated with the State. This backreference can be used by States to
|
|
transition the Context to another State.
|
|
"""
|
|
|
|
@property
|
|
def context(self) -> Context:
|
|
return self._context
|
|
|
|
@context.setter
|
|
def context(self, context: Context) -> None:
|
|
self._context = context
|
|
|
|
@abstractmethod
|
|
def handle1(self) -> None:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def handle2(self) -> None:
|
|
pass
|