(1)工厂模式(抽象类)
核心元素: 工厂基类 ,具体产品类
1.1 工厂基类
public abstract class IBaseFactory{
public abstract void createProduct(String productType);//创建某某类
public abstract void managerProduct(String productType);//管理某某类
}
1.2 产品类
public class BeerProduct extends IBaseFactory{
@Autowired
private IMakeBeerProductmakeBeerProduct;
public abstract void createProduct(String productType){
makeBeerProduct.createrProduct(productType);//具体去实现方法
}
public abstract void managerProduct(String productType){
}
}
1.3 产品接口方法
public interface IMakeBeerProduct{
void createrProduct(String productType);
}
@Service
public class MakeBeerProduct implements IMakeBeerProduct{
public void createrProduct(String productType){
System.out.println("creater Product");
}
}