Design Patterns III - Strategy pattern
Strategy pattern principle is create a interface strategy with methods definitions. The concrete strategies will implement the interface. And context will use interface strategy. With different strategy contexts, different strategies will be called.
UML:
Implementation:
There is an interface who is the strategy, it defines a method signature.
Two concrete class implement it and its method.
In a context class, it uses interface strategy as its parameter in its constrcutor. Its execute strategy method will call the interface strategy method.
Usage of strategy: