carfield.com.hk Aluminum.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:Aluminum.java // The Aluminum class with prototyping. package c12.trash; public class Aluminum extends Trash { private static double val = 1.67f; public Aluminum(double wt) { super(wt); } public double getValue() { return val; } public static void setValue(double newVal) { val = newVal; } } ///:~ </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 Cardboard.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:Cardboard.java // The Cardboard class with prototyping. package c12.trash; public class Cardboard extends Trash { private static double val = 0.23f; public Cardboard(double wt) { super(wt); } public double getValue() { return val; } public static void setValue(double newVal) { val = newVal; } } ///:~ </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 DynaTrash.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:dynatrash:DynaTrash.java // Using a Map of Lists and RTTI // to automatically sort trash into // ArrayLists. This solution, despite the // use of RTTI, is extensible. import c12.trash.*; import java.util.*; import com.bruceeckel.test.*; // Generic TypeMap works in any situation: class TypeMap { private Map t = new HashMap(); public void add(Object o) { Class type = o.getClass(); if(t.containsKey(type)) ((List)t.get(type)).add(o); else { List v = new ArrayList(); v.add(o); t.put(type,v); } } public List get(Class type) { return (List)t.get(type); } public Iterator keys() { return t.keySet().iterator(); } } // Adapter class to allow callbacks // from ParseTrash.fillBin(): class TypeMapAdapter implements Fillable { TypeMap map; public TypeMapAdapter(TypeMap tm) { map = tm; } public void addTrash(Trash t) { map.add(t); } } public class DynaTrash extends UnitTest { TypeMap bin = new TypeMap(); public DynaTrash() { ParseTrash.fillBin(&quot;../trash/Trash.dat&quot;, new TypeMapAdapter(bin)); } public void test() { Iterator keys = bin.keys(); while(keys.hasNext()) Trash.sumValue( bin.get((Class)keys.next()).iterator()); } public static void main(String args[]) { new DynaTrash().test(); } } ///:~ </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 Fillable.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:Fillable.java // Any object that can be filled with Trash. package c12.trash; public interface Fillable { void addTrash(Trash t); } ///:~ </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 FillableCollection.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:FillableCollection.java // Adapter that makes a Collection Fillable. package c12.trash; import java.util.*; public class FillableCollection implements Fillable { private Collection c; public FillableCollection(Collection cc) { c = cc; } public void addTrash(Trash t) { c.add(t); } } ///:~ </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 FillableVisitor.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trashvisitor:FillableVisitor.java // Adapter Decorator that adds the visitable // decorator as the Trash objects are // being created. import c12.trash.*; import java.util.*; public class FillableVisitor implements Fillable { private Fillable f; public FillableVisitor(Fillable ff) { f = ff; } public void addTrash(Trash t) { f.addTrash(new VisitableDecorator(t)); } } ///:~ </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 Glass.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:Glass.java // The Glass class with prototyping. package c12.trash; public class Glass extends Trash { private static double val = 0.23f; public Glass(double wt) { super(wt); } public double getValue() { return val; } public static void setValue(double newVal) { val = newVal; } } ///:~ </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 Paper.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:Paper.java // The Paper class with prototyping. package c12.trash; public class Paper extends Trash { private static double val = 0.10f; public Paper(double wt) { super(wt); } public double getValue() { return val; } public static void setValue(double newVal) { val = newVal; } } ///:~ </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 ParseTrash.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:ParseTrash.java // Parse file contents into Trash objects, // placing each into a Fillable holder. package c12.trash; import java.util.*; import java.io.*; import com.bruceeckel.util.StringList; public class ParseTrash { public static void fillBin(String filename, Fillable bin) { Iterator it = new StringList(filename).iterator(); while(it.hasNext()) { String line = (String)it.next(); String type = line.substring(0, line.indexOf(':')).trim(); double weight = Double.valueOf( line.substring(line.indexOf(':') + 1) .trim()).doubleValue(); bin.addTrash( Trash.factory( new Trash.Messenger(type, weight))); } } // Special case to handle Collection: public static void fillBin(String filename, Collection bin) { fillBin(filename, new FillableCollection(bin)); } } ///:~ </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 RecycleA.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:recyclea:RecycleA.java // Recycling with RTTI. import java.util.*; import java.io.*; import com.bruceeckel.test.*; abstract class Trash { private double weight; Trash(double wt) { weight = wt; } abstract double getValue(); double getWeight() { return weight; } // Sums the value of Trash in a bin: static void sumValue(Iterator it) { double val = 0.0f; while(it.hasNext()) { // One kind of RTTI: // A dynamically-checked cast Trash t = (Trash)it.next(); // Polymorphism in action: val += t.getWeight() * t.getValue(); System.out.println( &quot;weight of &quot; + // Using RTTI to get type // information about the class: t.getClass().getName() + &quot; = &quot; + t.getWeight()); } System.out.println(&quot;Total value = &quot; + val); } } class Aluminum extends Trash { static double val = 1.67f; Aluminum(double wt) { super(wt); } double getValue() { return val; } static void setValue(double newval) { val = newval; } } class Paper extends Trash { static double val = 0.10f; Paper(double wt) { super(wt); } double getValue() { return val; } static void setValue(double newval) { val = newval; } } class Glass extends Trash { static double val = 0.23f; Glass(double wt) { super(wt); } double getValue() { return val; } static void setValue(double newval) { val = newval; } } public class RecycleA extends UnitTest { Collection bin = new ArrayList(), glassBin = new ArrayList(), paperBin = new ArrayList(), alBin = new ArrayList(); public RecycleA() { // Fill up the Trash bin: for(int i = 0; i &lt; 30; i++) switch((int)(Math.random() * 3)) { case 0 : bin.add(new Aluminum(Math.random() * 100)); break; case 1 : bin.add(new Paper(Math.random() * 100)); break; case 2 : bin.add(new Glass(Math.random() * 100)); } } public void test() { Iterator sorter = bin.iterator(); // Sort the Trash: while(sorter.hasNext()) { Object t = sorter.next(); // RTTI to show class membership: if(t instanceof Aluminum) alBin.add(t); if(t instanceof Paper) paperBin.add(t); if(t instanceof Glass) glassBin.add(t); } Trash.sumValue(alBin.iterator()); Trash.sumValue(paperBin.iterator()); Trash.sumValue(glassBin.iterator()); Trash.sumValue(bin.iterator()); } public static void main(String args[]) { new RecycleA().test(); } } ///:~ </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 RecycleAP.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:recycleap:RecycleAP.java // Recycling with RTTI and Prototypes. import c12.trash.*; import java.util.*; import com.bruceeckel.test.*; public class RecycleAP extends UnitTest { Collection bin = new ArrayList(), glassBin = new ArrayList(), paperBin = new ArrayList(), alBin = new ArrayList(); public RecycleAP() { // Fill up the Trash bin: ParseTrash.fillBin( &quot;../trash/Trash.dat&quot;, bin); } public void test() { Iterator sorter = bin.iterator(); // Sort the Trash: while(sorter.hasNext()) { Object t = sorter.next(); // RTTI to show class membership: if(t instanceof Aluminum) alBin.add(t); if(t instanceof Paper) paperBin.add(t); if(t instanceof Glass) glassBin.add(t); } Trash.sumValue(alBin.iterator()); Trash.sumValue(paperBin.iterator()); Trash.sumValue(glassBin.iterator()); Trash.sumValue(bin.iterator()); } public static void main(String args[]) { new RecycleAP().test(); } } ///:~ </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 RecycleB.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:recycleb:RecycleB.java // Containers that grab objects of interest. import c12.trash.*; import java.util.*; import com.bruceeckel.test.*; // A container that admits only the right type // of Trash (established in the constructor): class Tbin { private Collection list = new ArrayList(); private Class type; public Tbin(Class binType) { type = binType; } public boolean grab(Trash t) { // Comparing class types: if(t.getClass().equals(type)) { list.add(t); return true; // Object grabbed } return false; // Object not grabbed } public Iterator iterator() { return list.iterator(); } } class TbinList extends ArrayList { void sort(Trash t) { Iterator e = iterator(); // Iterate over self while(e.hasNext()) if(((Tbin)e.next()).grab(t)) return; // Need a new Tbin for this type: add(new Tbin(t.getClass())); sort(t); // Recursive call } } public class RecycleB extends UnitTest { Collection bin = new ArrayList(); TbinList trashBins = new TbinList(); public RecycleB() { ParseTrash.fillBin(&quot;../trash/Trash.dat&quot;,bin); } public void test() { Iterator it = bin.iterator(); while(it.hasNext()) trashBins.sort((Trash)it.next()); Iterator e = trashBins.iterator(); while(e.hasNext()) { Tbin b = (Tbin)e.next(); Trash.sumValue(b.iterator()); } Trash.sumValue(bin.iterator()); } public static void main(String args[]) { new RecycleB().test(); } } ///:~ </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 Trash.dat 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <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 Trash.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trash:Trash.java // Base class for Trash recycling examples. package c12.trash; import java.util.*; import java.lang.reflect.*; public abstract class Trash { private double weight; public Trash(double wt) { weight = wt; } public Trash() {} public abstract double getValue(); public double getWeight() { return weight; } // Sums the value of Trash given an // Iterator to any container of Trash: public static void sumValue(Iterator it) { double val = 0.0f; while(it.hasNext()) { // One kind of RTTI: // A dynamically-checked cast Trash t = (Trash)it.next(); val += t.getWeight() * t.getValue(); System.out.println( &quot;weight of &quot; + // Using RTTI to get type // information about the class: t.getClass().getName() + &quot; = &quot; + t.getWeight()); } System.out.println(&quot;Total value = &quot; + val); } // Remainder of class provides // support for prototyping: private static List trashTypes = new ArrayList(); public static Trash factory(Messenger info) { for(int i = 0; i &lt; trashTypes.size(); i++) { // Somehow determine the new type // to create, and create one: Class tc = (Class)trashTypes.get(i); if (tc.getName().indexOf(info.id) != -1) { try { // Get the dynamic constructor method // that takes a double argument: Constructor ctor = tc.getConstructor( new Class[]{ double.class }); // Call the constructor // to create a new object: return (Trash)ctor.newInstance( new Object[]{new Double(info.data)}); } catch(Exception ex) { ex.printStackTrace(System.err); throw new RuntimeException( &quot;Cannot Create Trash&quot;); } } } // Class was not in the list. Try to load it, // but it must be in your class path! try { System.out.println(&quot;Loading &quot; + info.id); trashTypes.add(Class.forName(info.id)); } catch(Exception e) { e.printStackTrace(System.err); throw new RuntimeException( &quot;Prototype not found&quot;); } // Loaded successfully. // Recursive call should work: return factory(info); } public static class Messenger { public String id; public double data; public Messenger(String name, double val) { id = name; data = val; } } } ///:~ </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 TrashVisitor.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trashvisitor:TrashVisitor.java // The &quot;visitor&quot; pattern with VisitableDecorators. import c12.trash.*; import java.util.*; import com.bruceeckel.test.*; // Specific group of algorithms packaged // in each implementation of Visitor: class PriceVisitor implements Visitor { private double alSum; // Aluminum private double pSum; // Paper private double gSum; // Glass private double cSum; // Cardboard public void visit(Aluminum al) { double v = al.getWeight() * al.getValue(); System.out.println( &quot;value of Aluminum= &quot; + v); alSum += v; } public void visit(Paper p) { double v = p.getWeight() * p.getValue(); System.out.println( &quot;value of Paper= &quot; + v); pSum += v; } public void visit(Glass g) { double v = g.getWeight() * g.getValue(); System.out.println( &quot;value of Glass= &quot; + v); gSum += v; } public void visit(Cardboard c) { double v = c.getWeight() * c.getValue(); System.out.println( &quot;value of Cardboard = &quot; + v); cSum += v; } void total() { System.out.println( &quot;Total Aluminum: $&quot; + alSum + &quot;\n Total Paper: $&quot; + pSum + &quot;\nTotal Glass: $&quot; + gSum + &quot;\nTotal Cardboard: $&quot; + cSum + &quot;\nTotal: $&quot; + (alSum + pSum + gSum + cSum)); } } class WeightVisitor implements Visitor { private double alSum; // Aluminum private double pSum; // Paper private double gSum; // Glass private double cSum; // Cardboard public void visit(Aluminum al) { alSum += al.getWeight(); System.out.println(&quot;weight of Aluminum = &quot; + al.getWeight()); } public void visit(Paper p) { pSum += p.getWeight(); System.out.println(&quot;weight of Paper = &quot; + p.getWeight()); } public void visit(Glass g) { gSum += g.getWeight(); System.out.println(&quot;weight of Glass = &quot; + g.getWeight()); } public void visit(Cardboard c) { cSum += c.getWeight(); System.out.println(&quot;weight of Cardboard = &quot; + c.getWeight()); } void total() { System.out.println( &quot;Total weight Aluminum: &quot; + alSum + &quot;\nTotal weight Paper: &quot; + pSum + &quot;\nTotal weight Glass: &quot; + gSum + &quot;\nTotal weight Cardboard: &quot; + cSum + &quot;\nTotal weight: &quot; + (alSum + pSum + gSum + cSum)); } } public class TrashVisitor extends UnitTest { Collection bin = new ArrayList(); PriceVisitor pv = new PriceVisitor(); WeightVisitor wv = new WeightVisitor(); public TrashVisitor() { ParseTrash.fillBin(&quot;../trash/Trash.dat&quot;, new FillableVisitor( new FillableCollection(bin))); } public void test() { Iterator it = bin.iterator(); while(it.hasNext()) { Visitable v = (Visitable)it.next(); v.accept(pv); v.accept(wv); } pv.total(); wv.total(); } public static void main(String args[]) { new TrashVisitor().test(); } } ///:~ </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 VAluminum.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trashvisitor:VAluminum.java // Taking the previous approach of creating a // specialized Aluminum for the visitor pattern. import c12.trash.*; public class VAluminum extends Aluminum implements Visitable { public VAluminum(double wt) { super(wt); } public void accept(Visitor v) { v.visit(this); } } ///:~ </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 Visitable.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trashvisitor:Visitable.java // An interface to add visitor functionality // to the Trash hierarchy without // modifying the base class. import c12.trash.*; interface Visitable { // The new method: void accept(Visitor v); } ///:~ </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 VisitableDecorator.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trashvisitor:VisitableDecorator.java // A decorator that adapts the generic Trash // classes to the visitor pattern. import c12.trash.*; import java.lang.reflect.*; public class VisitableDecorator extends Trash implements Visitable { private Trash delegate; private Method dispatch; public VisitableDecorator(Trash t) { delegate = t; try { dispatch = Visitor.class.getMethod ( &quot;visit&quot;, new Class[] { t.getClass() } ); } catch (Exception ex) { ex.printStackTrace(); } } public double getValue() { return delegate.getValue(); } public double getWeight() { return delegate.getWeight(); } public void accept(Visitor v) { try { dispatch.invoke(v, new Object[]{delegate}); } catch (Exception ex) { ex.printStackTrace(); } } } ///:~ </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 Visitor.java 2001-12-26T16:00:00Z 2001-12-26T16:00:00Z <br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c12:trashvisitor:Visitor.java // The base interface for visitors. import c12.trash.*; interface Visitor { void visit(Aluminum a); void visit(Paper p); void visit(Glass g); void visit(Cardboard c); } ///:~ </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 .\c12\trashvisitor # 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: \ Visitable.class \ Visitor.class \ VAluminum.class \ VisitableDecorator.class \ FillableVisitor.class \ TrashVisitor.class jikes: \ Visitable.class \ Visitor.class \ VAluminum.class \ VisitableDecorator.class \ FillableVisitor.class \ TrashVisitor.class clean: ifeq ($(notdir $(SHELL)),COMMAND.COM) del *.class else rm -f *.class endif Visitable.class: Visitable.java Visitor.class: Visitor.java VAluminum.class: VAluminum.java VisitableDecorator.class: VisitableDecorator.java FillableVisitor.class: FillableVisitor.java TrashVisitor.class: TrashVisitor.java $(JVC) $(JVCFLAGS) $&lt; java com.bruceeckel.test.RunUnitTests TrashVisitor </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