package com.jmj.pattern.strategy;
public interface Strategy {
package com.jmj.pattern.strategy;
public class StrategyA implements Strategy{
System.out.println("买一送一");
package com.jmj.pattern.strategy;
public class StrategyB implements Strategy{
System.out.println("买两百减五十");
package com.jmj.pattern.strategy;
public class StrategyC implements Strategy{
System.out.println("满1000加一元");
package com.jmj.pattern.strategy;
private Strategy strategy;
public SalesMan(Strategy strategy) {
this.strategy = strategy;
public void salesManshow(){
package com.jmj.pattern.strategy;
public static void main(String[] args) {
SalesMan salesMan = new SalesMan(new StrategyA());