package headfirst.factory.pizzas.pizzafactory; import headfirst.factory.pizzas.pizza.CheesePizza; import headfirst.factory.pizzas.pizza.ClamPizza; import headfirst.factory.pizzas.pizza.PepperoniPizza; import headfirst.factory.pizzas.pizza.Pizza; import headfirst.factory.pizzas.pizza.VeggiePizza; public class SimplePizzaFactory { public Pizza createPizza(String type) { Pizza pizza = null; if (type.equals("cheese")) { pizza = new CheesePizza(); } else if (type.equals("pepperoni")) { pizza = new PepperoniPizza(); } else if (type.equals("clam")) { pizza = new ClamPizza(); } else if (type.equals("veggie")) { pizza = new VeggiePizza(); } return pizza; } }
内容样式!!!!!!!!!
时间: 2024-10-09 19:55:34