public abstract class Pizaa{
...
}
public class CheesePizza extends Pizaa{
...
}
public class ClamPizza extends Pizaa{
...
}
public class VeggiePizza extends Pizaa{
...
}
public class SimplePizzaFactory{
public static Pizza creatPizza (String type){//为什么通常声明为静态
Pizza pizza = null;
if(type.equals("cheese")){
pizza = new CheesePizza();
}else if(type.equals("Clam")){
pizza = new ClamPizza();
}else if(type.equals("Veggie")){
pizza = new VeggiePizza();
}
return pizza;
}
}
public class PazzaStore{
SimplePizzaFactory factory;
public PizzaStore(SimplePizzaFactory factory){
this.factory = factory;
}
public Pizza orderPizza(String type){
Pizaa pizza;
pizza = factory.createPizza(type);
public abstract prepare();
public abstract bake();
public abstract cut();
public abstract box();
return pizza;
}
}