carfield.com.hk
Amaze.txt
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/> * ** * * ** *<br/> *** * ******* * ****<br/> *** *** <br/> ***** ********** *****<br/> * * * * ** ** * * * ** *<br/> * * * * ** * * * * **<br/> * ** * ** <br/> * ** * ** * ** * **<br/> *** * *** ***** * *** **<br/> * * * * * * <br/> * ** * * * ** * * <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
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 = "Cappucino";
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 =
"Cafe Mocha decaf whipped cream";
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()
+ ": $" + 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()
+ ": $" + 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
Maze.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c13:Maze.java
import java.util.*;
import java.io.*;
import java.awt.*;
public class Maze extends Canvas {
private Vector lines; // a line is a char array
private int width = -1;
private int height = -1;
public static void main (String [] args)
throws IOException {
if (args.length < 1) {
System.out.println("Enter filename");
System.exit(0);
}
Maze m = new Maze();
m.load(args[0]);
Frame f = new Frame();
f.setSize(m.width*20, m.height*20);
f.add(m);
Rat r = new Rat(m, 0, 0);
f.setVisible(true);
}
public Maze() {
lines = new Vector();
setBackground(Color.lightGray);
}
synchronized public boolean
isEmptyXY(int x, int y) {
if (x < 0) x += width;
if (y < 0) y += height;
// Use mod arithmetic to bring rat in line:
byte[] by =
(byte[])(lines.elementAt(y%height));
return by[x%width]==' ';
}
synchronized public void
setXY(int x, int y, byte newByte) {
if (x < 0) x += width;
if (y < 0) y += height;
byte[] by =
(byte[])(lines.elementAt(y%height));
by[x%width] = newByte;
repaint();
}
public void
load(String filename) throws IOException {
String currentLine = null;
BufferedReader br = new BufferedReader(
new FileReader(filename));
for(currentLine = br.readLine();
currentLine != null;
currentLine = br.readLine()) {
lines.addElement(currentLine.getBytes());
if(width < 0 ||
currentLine.getBytes().length > width)
width = currentLine.getBytes().length;
}
height = lines.size();
br.close();
}
public void update(Graphics g) { paint(g); }
public void paint (Graphics g) {
int canvasHeight = this.getBounds().height;
int canvasWidth = this.getBounds().width;
if (height < 1 || width < 1)
return; // nothing to do
int width =
((byte[])(lines.elementAt(0))).length;
for (int y = 0; y < lines.size(); y++) {
byte[] b;
b = (byte[])(lines.elementAt(y));
for (int x = 0; x < width; x++) {
switch(b[x]) {
case ' ': // empty part of maze
g.setColor(Color.lightGray);
g.fillRect(
x*(canvasWidth/width),
y*(canvasHeight/height),
canvasWidth/width,
canvasHeight/height);
break;
case '*': // a wall
g.setColor(Color.darkGray);
g.fillRect(
x*(canvasWidth/width),
y*(canvasHeight/height),
(canvasWidth/width)-1,
(canvasHeight/height)-1);
break;
default: // must be rat
g.setColor(Color.red);
g.fillOval(x*(canvasWidth/width),
y*(canvasHeight/height),
canvasWidth/width,
canvasHeight/height);
break;
}
}
}
}
} ///:~
</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
PyUtil.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: com:bruceeckel:python:PyUtil.java
// PythonInterpreter utilities
package com.bruceeckel.python;
import org.python.util.PythonInterpreter;
import org.python.core.*;
import java.util.*;
public class PyUtil {
/** Extract a Python tuple or array into a Java
List (which can be converted into other kinds
of lists and sets inside Java).
@param interp The Python interpreter object
@param pyName The id of the python list object
*/
public static List
toList(PythonInterpreter interp, String pyName){
return new ArrayList(Arrays.asList(
(Object[])interp.get(
pyName, Object[].class)));
}
/** Extract a Python dictionary into a Java Map
@param interp The Python interpreter object
@param pyName The id of the python dictionary
*/
public static Map
toMap(PythonInterpreter interp, String pyName){
PyList pa = ((PyDictionary)interp.get(
pyName)).items();
Map map = new HashMap();
while(pa.__len__() != 0) {
PyTuple po = (PyTuple)pa.pop();
Object first = po.__finditem__(0)
.__tojava__(Object.class);
Object second = po.__finditem__(1)
.__tojava__(Object.class);
map.put(first, second);
}
return map;
}
/** Turn a Java Map into a PyDictionary,
suitable for placing into a PythonInterpreter
@param map The Java Map object
*/
public static PyDictionary
toPyDictionary(Map map) {
Map m = new HashMap();
Iterator it = map.entrySet().iterator();
while(it.hasNext()) {
Map.Entry e = (Map.Entry)it.next();
m.put(Py.java2py(e.getKey()),
Py.java2py(e.getValue()));
}
// PyDictionary constructor wants a Hashtable:
return new PyDictionary(new Hashtable(m));
}
} ///:~
</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
Rat.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: c13:Rat.java
public class Rat {
static int ratCount = 0;
private Maze prison;
private int vertDir = 0;
private int horizDir = 0;
private int x,y;
private int myRatNo = 0;
public Rat(Maze maze, int xStart, int yStart) {
myRatNo = ratCount++;
System.out.println("Rat no." + myRatNo +
" ready to scurry.");
prison = maze;
x = xStart;
y = yStart;
prison.setXY(x,y, (byte)'R');
new Thread() {
public void run(){ scurry(); }
}.start();
}
public void scurry() {
// Try and maintain direction if possible.
// Horizontal backward
boolean ratCanMove = true;
while(ratCanMove) {
ratCanMove = false;
// South
if (prison.isEmptyXY(x, y + 1)) {
vertDir = 1; horizDir = 0;
ratCanMove = true;
}
// North
if (prison.isEmptyXY(x, y - 1))
if (ratCanMove)
new Rat(prison, x, y-1);
// Rat can move already, so give
// this choice to the next rat.
else {
vertDir = -1; horizDir = 0;
ratCanMove = true;
}
// West
if (prison.isEmptyXY(x-1, y))
if (ratCanMove)
new Rat(prison, x-1, y);
// Rat can move already, so give
// this choice to the next rat.
else {
vertDir = 0; horizDir = -1;
ratCanMove = true;
}
// East
if (prison.isEmptyXY(x+1, y))
if (ratCanMove)
new Rat(prison, x+1, y);
// Rat can move already, so give
// this choice to the next rat.
else {
vertDir = 0; horizDir = 1;
ratCanMove = true;
}
if (ratCanMove) { // Move original rat.
x += horizDir;
y += vertDir;
prison.setXY(x,y,(byte)'R');
} // If not then the rat will die.
try {
Thread.sleep(2000);
} catch(InterruptedException ie) {}
}
System.out.println("Rat no." + myRatNo +
" can't move..dying..aarrgggh.");
}
} ///:~
</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
RunUnitTests.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: com:bruceeckel:test:RunUnitTests.java
// Discovering the unit test
// class and running each test.
package com.bruceeckel.test;
import java.lang.reflect.*;
import java.util.Iterator;
public class RunUnitTests {
public static void
require(boolean requirement, String errmsg) {
if(!requirement) {
System.err.println(errmsg);
System.exit(1);
}
}
public static void main(String[] args) {
require(args.length == 1,
"Usage: RunUnitTests qualified-class");
try {
Class c = Class.forName(args[0]);
// Only finds the inner classes
// declared in the current class:
Class[] classes = c.getDeclaredClasses();
Class ut = null;
for(int j = 0; j < classes.length; j++) {
// Skip inner classes that are
// not derived from UnitTest:
if(!UnitTest.class.
isAssignableFrom(classes[j]))
continue;
ut = classes[j];
break; // Finds the first test class only
}
// If it found an inner class,
// that class must be static:
if(ut != null)
require(
Modifier.isStatic(ut.getModifiers()),
"inner UnitTest class must be static");
// If it couldn't find the inner class,
// maybe it's a regular class (for black-
// box testing:
if(ut == null)
if(UnitTest.class.isAssignableFrom(c))
ut = c;
require(ut != null,
"No UnitTest class found");
require(
Modifier.isPublic(ut.getModifiers()),
"UnitTest class must be public");
Method[] methods = ut.getDeclaredMethods();
for(int k = 0; k < methods.length; k++) {
Method m = methods[k];
// Ignore overridden UnitTest methods:
if(m.getName().equals("cleanup"))
continue;
// Only public methods with no
// arguments and void return
// types will be used as test code:
if(m.getParameterTypes().length == 0 &&
m.getReturnType() == void.class &&
Modifier.isPublic(m.getModifiers())) {
// The name of the test is
// used in error messages:
UnitTest.testID = m.getName();
// A new instance of the
// test object is created and
// cleaned up for each test:
Object test = ut.newInstance();
m.invoke(test, new Object[0]);
((UnitTest)test).cleanup();
}
}
} catch(Exception e) {
e.printStackTrace(System.err);
// Any exception will return a nonzero
// value to the console, so that
// 'make' will abort:
System.err.println("Aborting make");
System.exit(1);
}
// After all tests in this class are run,
// display any results. If there were errors,
// abort 'make' by returning a nonzero value.
if(UnitTest.errors.size() != 0) {
Iterator it = UnitTest.errors.iterator();
while(it.hasNext())
System.err.println(it.next());
System.exit(1);
}
}
} ///:~
</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
StringList.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: com:bruceeckel:util:StringList.java
// General-purpose tool that reads a file of text
// lines into a List, one line per list.
package com.bruceeckel.util;
import java.io.*;
import java.util.*;
public class StringList extends ArrayList {
public StringList(String textFile) {
try {
BufferedReader inputs =
new BufferedReader (
new FileReader(textFile));
String line;
while((line = inputs.readLine()) != null)
add(line.trim());
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
} ///:~
</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
Test.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: com:bruceeckel:python:Test.java
package com.bruceeckel.python;
import org.python.util.PythonInterpreter;
import java.util.*;
import com.bruceeckel.test.*;
public class Test extends UnitTest {
PythonInterpreter pi =
new PythonInterpreter();
public void test1() {
pi.exec("tup=('fee','fi','fo','fum','fi')");
List lst = PyUtil.toList(pi, "tup");
System.out.println(lst);
System.out.println(new HashSet(lst));
}
public void test2() {
pi.exec("ints=[1,3,5,7,9,11,13,17,19]");
List lst = PyUtil.toList(pi, "ints");
System.out.println(lst);
}
public void test3() {
pi.exec("dict = { 1 : 'a', 3 : 'b', " +
"5 : 'c', 9 : 'd', 11 : 'e'}");
Map mp = PyUtil.toMap(pi, "dict");
System.out.println(mp);
}
public void test4() {
Map m = new HashMap();
m.put("twas", new Integer(11));
m.put("brillig", new Integer(27));
m.put("and", new Integer(47));
m.put("the", new Integer(42));
m.put("slithy", new Integer(33));
m.put("toves", new Integer(55));
System.out.println(m);
pi.set("m", PyUtil.toPyDictionary(m));
pi.exec("print m");
pi.exec("print m['slithy']");
}
public static void main(String args[]) {
Test t = new Test();
t.test1();
t.test2();
t.test3();
t.test4();
}
} ///:~
</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 "visitor" 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(
"value of Aluminum= " + v);
alSum += v;
}
public void visit(Paper p) {
double v = p.getWeight() * p.getValue();
System.out.println(
"value of Paper= " + v);
pSum += v;
}
public void visit(Glass g) {
double v = g.getWeight() * g.getValue();
System.out.println(
"value of Glass= " + v);
gSum += v;
}
public void visit(Cardboard c) {
double v = c.getWeight() * c.getValue();
System.out.println(
"value of Cardboard = " + v);
cSum += v;
}
void total() {
System.out.println(
"Total Aluminum: $" + alSum +
"\n Total Paper: $" + pSum +
"\nTotal Glass: $" + gSum +
"\nTotal Cardboard: $" + cSum +
"\nTotal: $" +
(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("weight of Aluminum = "
+ al.getWeight());
}
public void visit(Paper p) {
pSum += p.getWeight();
System.out.println("weight of Paper = "
+ p.getWeight());
}
public void visit(Glass g) {
gSum += g.getWeight();
System.out.println("weight of Glass = "
+ g.getWeight());
}
public void visit(Cardboard c) {
cSum += c.getWeight();
System.out.println("weight of Cardboard = "
+ c.getWeight());
}
void total() {
System.out.println(
"Total weight Aluminum: " + alSum +
"\nTotal weight Paper: " + pSum +
"\nTotal weight Glass: " + gSum +
"\nTotal weight Cardboard: " + cSum +
"\nTotal weight: " +
(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("../trash/Trash.dat",
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
TypedIterator.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: com:bruceeckel:util:TypedIterator.java
package com.bruceeckel.util;
import java.util.*;
public class TypedIterator implements Iterator {
private Iterator imp;
private Class type;
public TypedIterator(Iterator it, Class type) {
imp = it;
this.type = type;
}
public boolean hasNext() {
return imp.hasNext();
}
public void remove() { imp.remove(); }
public Object next() {
Object obj = imp.next();
if(!type.isInstance(obj))
throw new ClassCastException(
"TypedIterator for type " + type +
" encountered type: " + obj.getClass());
return obj;
}
} ///:~
</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
UnitTest.java
2001-12-26T16:00:00Z
2001-12-26T16:00:00Z
<br/><TEXTAREA name="code" class="java" rows="16" cols="100">//: com:bruceeckel:test:UnitTest.java
// The basic unit testing class
package com.bruceeckel.test;
import java.util.*;
public class UnitTest {
static String testID;
static List errors = new ArrayList();
// Override cleanup() if test object
// creation allocates non-memory
// resources that must be cleaned up:
protected void cleanup() {}
// Verify the truth of a condition:
protected final void affirm(boolean condition){
if(!condition)
errors.add("failed: " + testID);
}
} ///:~
</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 (
"visit", 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 .\com\bruceeckel\util
# 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) $<
javac: \
StringList.class \
TypedIterator.class
jikes: \
StringList.class \
TypedIterator.class
clean:
ifeq ($(notdir $(SHELL)),COMMAND.COM)
del *.class
else
rm -f *.class
endif
StringList.class: StringList.java
TypedIterator.class: TypedIterator.java
</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