Skip to content

Instantly share code, notes, and snippets.

@erubboli
Created September 7, 2010 08:40
Show Gist options
  • Save erubboli/568044 to your computer and use it in GitHub Desktop.
Save erubboli/568044 to your computer and use it in GitHub Desktop.
class PizzaFactory {
public enum PizzaType {
HamMushroom,
Deluxe,
Hawaiian
}
public static Pizza createPizza(PizzaType pizzaType) {
switch (pizzaType) {
case HamMushroom:
return new HamAndMushroomPizza();
case Deluxe:
return new DeluxePizza();
case Hawaiian:
return new HawaiianPizza();
}
throw new IllegalArgumentException("The pizza type " + pizzaType + " is not recognized.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment