added strategy example
This commit is contained in:
17
src/learn/simple_strategy/Context.java
Normal file
17
src/learn/simple_strategy/Context.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package learn.simple_strategy;
|
||||
|
||||
public class Context {
|
||||
private Strategy currentStrategy;
|
||||
|
||||
public Context(Strategy currentStrategy) {
|
||||
this.currentStrategy = currentStrategy;
|
||||
}
|
||||
|
||||
public void setCurrentStrategy(Strategy currentStrategy) {
|
||||
this.currentStrategy = currentStrategy;
|
||||
}
|
||||
|
||||
public void doSomeJob() {
|
||||
currentStrategy.algorithm();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user