carfield.com.hk CoffeeShop.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: cX:decorator:nodecorators:CoffeeShop.java // Coffee example with no decorators package cX.decorator.nodecorators; import com.bruceeckel.test.UnitTest; class Espresso {} class DoubleEspresso {} class EspressoConPanna {} class Cappuccino { private float cost = 1; private String description = &quot;Cappucino&quot;; public float getCost() { return cost; } public String getDescription() { return description; } } class CappuccinoDecaf {} class CappuccinoDecafWhipped {} class CappuccinoDry {} class CappuccinoDryWhipped {} class CappuccinoExtraEspresso {} class CappuccinoExtraEspressoWhipped {} class CappuccinoWhipped {} class CafeMocha {} class CafeMochaDecaf {} class CafeMochaDecafWhipped { private float cost = 1.25f; private String description = &quot;Cafe Mocha decaf whipped cream&quot;; public float getCost() { return cost; } public String getDescription() { return description; } } class CafeMochaExtraEspresso {} class CafeMochaExtraEspressoWhipped {} class CafeMochaWet {} class CafeMochaWetWhipped {} class CafeMochaWhipped {} class CafeLatte {} class CafeLatteDecaf {} class CafeLatteDecafWhipped {} class CafeLatteExtraEspresso {} class CafeLatteExtraEspressoWhipped {} class CafeLatteWet {} class CafeLatteWetWhipped {} class CafeLatteWhipped {} public class CoffeeShop extends UnitTest { public void testCappuccino() { // This just makes sure it will complete // without throwing an exception. // Create a plain cappuccino Cappuccino cappuccino = new Cappuccino(); System.out.println(cappuccino.getDescription() + &quot;: $&quot; + cappuccino.getCost()); } public void testCafeMocha() { // This just makes sure it will complete // without throwing an exception. // Create a decaf cafe mocha with whipped // cream CafeMochaDecafWhipped cafeMocha = new CafeMochaDecafWhipped(); System.out.println(cafeMocha.getDescription() + &quot;: $&quot; + cafeMocha.getCost()); } public static void main(String[] args) { CoffeeShop shop = new CoffeeShop(); shop.testCappuccino(); shop.testCafeMocha(); } } ///:~ </TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2001-12-26T16:00:00Z makefile 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="" rows="16" cols="100"># From Thinking in Patterns (with Java) by Bruce Eckel # At http://www.BruceEckel.com # (c)2001 Bruce Eckel # Copyright notice in Copyright.txt # Automatically-generated MAKEFILE # For examples in directory .\cX\decorator\nodecorators # using the JDK 1.3 compiler # Invoke with: make HOME := ../../../ ifndef MAKECMDGOALS MAKECMDGOALS := javac endif # Command.com is too weak to build this under Windows NT/2000: ifeq ($(OS),Windows_NT) COMSPEC=$(SYSTEMROOT)\system32\cmd.exe endif ifneq ($(MAKECMDGOALS),clean) include $(HOME)/$(MAKECMDGOALS).mac endif .SUFFIXES : .class .java .java.class : $(JVC) $(JVCFLAGS) $&lt; javac: \ CoffeeShop.class jikes: \ CoffeeShop.class clean: ifeq ($(notdir $(SHELL)),COMMAND.COM) del *.class else rm -f *.class endif CoffeeShop.class: CoffeeShop.java $(JVC) $(JVCFLAGS) $&lt; java com.bruceeckel.test.RunUnitTests cX.decorator.nodecorators.CoffeeShop </TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> 2001-12-26T16:00:00Z