CS 342 - 4/7/16 Decorator Design Pattern public abtract class Beverage { String descrip = "Unknown Beverage": public String getDescription() { return descrip; } public abstract double cost(); } public class Espresso extends Beverage { public Espresso() { descrip = "Espresso"; } public double cost () { return 9.78; } } public abstract class CondimentDecorator extends Beverage { public abstract String getDescription (); } public class Mocha extend CondimentDecorator { Beverage bev; public Mocha (Beverage bevParam) { bev = bevParam; } public Sgtring getDescription() { return bev.getDescription() + ", Mocha"; } public double cost() { return 18.95 + bev.cost(); } } // Beverage customerOrder; customerOrder = new Espresso(); System.out.println ("The customer odered a " + customerOrder.getDescription() + " which costs $" + customerOrder.cost() ); customerOrder = new Mocha ( customerOrder ); System.out.println ("The customer odered a " + customerOrder.getDescription() + " which costs $" + customerOrder.cost() ); customerOrder = new Cream ( customerOrder ); customerOrder = new Sugar ( customerOrder ); customerOrder = new Sugar ( customerOrder ); ================================================ public static void main(String[] args) { String word; word = new String ("Hello"); method2 ( word ); System.out.println(word); } public static void method2 ( String p ) { p = new String ("Goodbye"); }