001package headfirst.templatemethod.barista; 002 003public abstract class CaffeineBeverageWithHook { 004 005 void prepareRecipe() { 006 boilWater(); 007 brew(); 008 pourInCup(); 009 if (customerWantsCondiments()) { 010 addCondiments(); 011 } 012 } 013 014 abstract void brew(); 015 016 abstract void addCondiments(); 017 018 void boilWater() { 019 System.out.println("Boiling water"); 020 } 021 022 void pourInCup() { 023 System.out.println("Pouring into cup"); 024 } 025 026 boolean customerWantsCondiments() { 027 return true; 028 } 029}