LLD - Behavioral Design Patterns — Part 1
Given the following code snippet using the Strategy pattern, what will be the output?
class Context:
def __init__(self, strategy):
self.strategy = strategy
def execute(self):
return self.strategy.do_action()
class StrategyA:
def do_action(self):
return 'Action A'
class StrategyB:
def do_action(self):
return 'Action B'
context = Context(StrategyB())
print(context.execute())