Welcome

首页 / 软件开发 / 数据结构与算法 / hand first设计模式 - 装饰者模式

hand first设计模式 - 装饰者模式2012-01-05 javaeye pan_java所有饮料抽象类

Java代码

public abstract class Beverage {   String description = "unknown beverage";   public String getDescription() {  return description;  }   public abstract double cost();  }
装饰者抽象类

Java代码

public abstract class CondimentDecorator extends Beverage {   public abstract String getDescription();   }
浓咖啡

Java代码

public class Espresso extends Beverage {   public Espresso(){  description = "Espresso";  }  @Override  public double cost() {  // TODO Auto-generated method stub  return 1.99;  }  }