TestCollatz - / / / / / -projects/collatz/TestCollatz.java...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// --------------------------------- // projects/collatz/TestCollatz.java // Copyright (C) 2010 // Glenn P. Downing // --------------------------------- /* To test the program: % setenv CLASSPATH .:/lusr/share/lib/java/junit/junit-4.5.jar % javac -Xlint TestCollatz.java % java -ea TestCollatz */ import java.io.PrintStream; import java.util.Scanner; import java.util.HashMap; import junit.framework.Assert; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; // ------ // Reader // ------ final class Reader { private int _c; private int _i; private int _j; public Reader (int i, int j) { _c = 0; _i = i; _j = j;} public boolean hasNextInt () { return (_c < 2);} public int nextInt () { switch (_c) { case 0: ++_c; return _i; case 1: ++_c; return _j; default: assert false;} return -1;}} // ------ // Writer // ------ final class Writer { private StringBuilder _sb; public Writer () {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
_sb = new StringBuilder();} public String toString () { return _sb.toString();} public void write (String s) { _sb.append(s + "\n");}} // -----------
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

TestCollatz - / / / / / -projects/collatz/TestCollatz.java...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online