Created
September 7, 2010 08:40
-
-
Save erubboli/568044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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