抽象工厂模式提供一个创建一系列相关或相互依赖对象的接口,而无须指定他们具体的类。它针对的是有多个产品的等级结构。
而工厂方法模式针对的是一个产品的等级结构。
工厂接口 只负责定义,具体实现 由实现该接口的具体实现类实现。
public interface Factory {
}
public class CarFactory implements Factory {
int weight ;
String name ;
public CarFactory(int weight, String name) {
super();
this.weight = weight;
this.name = name;
}
}