design-patterns/behavioral/mediator/components.py
Ruidy edcd5d35d7
Mediator (#18)
* doc: add documentation

* doc: edit general documentation

* add code example
2020-10-02 17:24:36 +02:00

25 lines
710 B
Python

"""
Concrete Components implement various functionality. They don't depend on other
components. They also don't depend on any concrete mediator classes.
"""
from behavioral.mediator.base_component import BaseComponent
class Component1(BaseComponent):
def do_a(self) -> None:
print("Component 1 does A.")
self.mediator.notify(self, "A")
def do_b(self) -> None:
print("Component 1 does B.")
self.mediator.notify(self, "B")
class Component2(BaseComponent):
def do_c(self) -> None:
print("Component 2 does C.")
self.mediator.notify(self, "C")
def do_d(self) -> None:
print("Component 2 does D.")
self.mediator.notify(self, "D")