据我了解,工厂方法是简单工厂,工厂对象是抽象工厂?和:
-工厂方法(简单工厂):
public class SimplePizzaFactory {
public static final int CHEESE = 1;
public static final int PEPPERONI = 2;
public static final int VEGGIE = 3;
public static Pizza createPizza(int type) {
Pizza pizza = null;
if (type == CHEESE) {
pizza = new CheesePizza();
} else if (type == PEPPERONI ) {
pizza = new PepperoniPizza();
} else if (type == VEGGIE ) {
pizza = new VeggiePizza();
}
return pizza;
}
}
工厂对象(抽象工厂):
?
我对吗?
工厂模式有多少实现,它们有什么区别?