mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
15 lines
440 B
Python
15 lines
440 B
Python
"""
|
|
Concrete Strategies implement the algorithm while following the base Strategy interface. The interface makes them
|
|
interchangeable in the Context.
|
|
"""
|
|
from behavioral.strategy.strategy import Strategy
|
|
|
|
|
|
class ConcreteStrategyA(Strategy):
|
|
def do_algorithm(self, data: list) -> list:
|
|
return sorted(data)
|
|
|
|
|
|
class ConcreteStrategyB(Strategy):
|
|
def do_algorithm(self, data: list) -> list:
|
|
return reversed(sorted(data))
|