18 lines
389 B
Java

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();
}
}