Created
July 27, 2012 08:31
-
-
Save robinp/3186839 to your computer and use it in GitHub Desktop.
bakery model using template method
This file contains 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
abstract class Bakery1 { | |
public void produceBread() { | |
Ingredients ingredients = prepareIngredients(); | |
Bread bread = bakeTheBread(ingredients); | |
if (checkQuality(bread)) { | |
putBreadOnDisplay(bread); | |
} | |
} | |
abstract Bread bakeTheBread(Ingredients ingredients); | |
// other methods are implemented | |
} | |
class WhiteBreadBakery1 extends Bakery1 { | |
@Override | |
Bread bakeTheBread(Ingredients ingredients) { | |
// magically mix ingredients into a white bread | |
} | |
} | |
class BioBreadBakery1 extends Bakery1 { | |
@Override | |
Bread bakeTheBread(Ingredients ingredients) { | |
// use more natural stuff so customers will be happy | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment