mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
15 lines
576 B
Python
15 lines
576 B
Python
"""
|
|
The client code picks a concrete strategy and passes it to the context.
|
|
The client should be aware of the differences between strategies in order to make the right choice.
|
|
"""
|
|
from behavioral.strategy.concrete_strategies import ConcreteStrategyA, ConcreteStrategyB
|
|
from behavioral.strategy.context import Context
|
|
|
|
context = Context(ConcreteStrategyA())
|
|
print("Client: Strategy is set to normal sorting.")
|
|
context.do_some_business_logic()
|
|
print()
|
|
|
|
print("Client: Strategy is set to reverse sorting.")
|
|
context.strategy = ConcreteStrategyB()
|
|
context.do_some_business_logic()
|