Computer Science 15-110, Spring 2010
Recitation for Week #3
public static void testAlmostEqual() { System.out.print("Testing almostEqual... "); double d1 = (29.0 / 7.0) * 7.0; double d2 = 29.0; assert(d1 != d2); assert(almostEqual(d1, d2)); // two very-nearly-equal values assert(almostEqual(-d1, -d2)); // and their negations System.out.println("Passed all tests!"); }
public static void testDistance() { System.out.print("Testing distance... "); assert(almostEqual(distance(0,0,0,0), 0)); assert(almostEqual(distance(0,0,1,0), 1)); assert(almostEqual(distance(1,0,0,0), 1)); assert(almostEqual(distance(0,0,1,1), Math.sqrt(2))); assert(almostEqual(distance(0,0,-1,1), Math.sqrt(2))); assert(almostEqual(distance(4,3,1,7), 5)); System.out.println("Passed all tests!"); }
carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem - carpe diem