package rebelsky.vec; import java.util.Vector; /** * An incrementally developed attempt to test Sam's Point.java * class. * * @author The students of CSC223 2004F * @version 1.0 */ public class TestPoint { public static Vector errors = new Vector(); public static void main(String[] args) throws Exception { for (double x = -4.0; x < 3.0; x += 0.1) for (double y = -3.0; y < 4.0; y += 0.3) { Point whatever = new Point(x,y); Vec2D extra = whatever.rotate(Math.PI).rotate(Math.PI); if (x!= whatever.getX()) errors.add("getX() failed with x of " + x); if (y!= whatever.getY()) errors.add("getY() failed with y of " + y); if (whatever.getX() != extra.getX()) errors.add("rotate failed with " + whatever + " and " + extra); } int size = errors.size(); if (size == 0) { System.err.println("All tests passed."); System.exit(0); } else { System.err.println(size + " tests failed."); for (int i = 0; i < size; i++) { System.err.println(errors.get(i)); } // for System.exit(1); } // else } // whatever.getX() } // class TestPoint