Question: java Is the following a correct implementation of the template pattern? Why or why not? abstract class Beverage { abstract void prepare(); void boilWater() {//
Is the following a correct implementation of the template pattern? Why or why not? abstract class Beverage \{ abstract void prepare(); void boilWater() {// code to boil water } void pourinCup() \{// code to pour in cup } 3 class Tea extends Beverage \{ void prepare() \{ boilWater(); steepTeaGrinds(); pourlnCup(); addLemonAndSugar(); \} void steepTeaGrinds() \{// code to steep tea grinds } void addLemonAndSugar() \{// code to add lemon and sugar } \} class Cofee extends Beverage \{ void prepare() \{ boilWater(); brewCoffeeGrinds(); pourinCup(); addMilkAndSugar(); \} void brewCoffeegrinds() \{// code to brew coffee grinds } void addMilkAndSugar() \{// code to add milk and sugar } \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
