体验新版 GitCode,发现更多精彩内容 >>
package com.chen.StrategyPattern; import com.chen.StrategyPattern.po.Strategy; /** * @author lx * @date 2021/10/13 11:30 **/ public class Context { /** * 本次策略规则对象 */ private final Strategy strategy; public Context(Strategy strategy) { this.strategy = strategy; } public int exec(int a, int b) { return strategy.exec(a, b); } }