public class ChicagoPizzaStore extends PizzaStore {
1
2
protected Pizza createPizza(String item) {
3
Pizza pizza = null;
4
PizzaIngredientFactory ingredientFactory =
5
new ChicagoPizzaIngredientFactory();
6
7
if (item.equals("cheese")) {
8
9
pizza = new CheesePizza(ingredientFactory);
10
pizza.setName("Chicago Style Cheese Pizza");
11
12
} else if (item.equals("veggie")) {
13
14
pizza = new VeggiePizza(ingredientFactory);
15
pizza.setName("Chicago Style Veggie Pizza");
16
17
} else if (item.equals("clam")) {
18
19
pizza = new ClamPizza(ingredientFactory);
20
pizza.setName("Chicago Style Clam Pizza");
21
22
} else if (item.equals("pepperoni")) {
23
24
pizza = new PepperoniPizza(ingredientFactory);
25
pizza.setName("Chicago Style Pepperoni Pizza");
26
27
}
28
return pizza;
29
}
30
}
31
32
factory method.