Context.java 400 字节
Newer Older
C
chenjianqiang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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);
    }
}