public abstract class caffeineBeverageWithHook
{
    
    void prepareRecipe()
    {
        boilWater();
        brew();
        pourIncup();
        if(customerWantsCondiments())
        {
            addCondiments();
        }
    }

    abstract void brew();
    abstract void addCondiments();

    VOid boilWater()
    {
        System.out.printLn("Boiling water");
    }
    
    void pourInCup()
    {
        system.out.println("Pouring into cup");
    }
    
    boolean customerWantsCondiments()
    {
        return true;
    }
}

相关文章:

  • 2021-12-24
  • 2021-12-06
  • 2021-09-11
  • 2021-10-27
  • 2022-12-23
  • 2021-10-02
  • 2021-06-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2021-10-27
  • 2021-08-09
  • 2021-06-07
  • 2022-01-26
相关资源
相似解决方案