/** * @(#)TestComplex.java * This tests the complex implementations * * @Cassel Sloan * @version 1.00 2007/1/31 */ import kthComplex.java; public class TestComplex { public static void main(String[] args) { System.out.println("Testing kthComplex static methods"); kthComplex a = new kthComplex(1.0, 1.0); kthComplex b = new kthComplex(1.0, 2.0); System.out.println("(1+1i)+(1+2i) = " + add(a,b)); System.out.println("(1+1i)-(1+2i) = " + subtract(a,b)); System.out.println("(1+1i)*(1+2i) = " + multiply(a,b)); System.out.println("(1+1i)/(1+2i) = " + divide(a,b)); System.out.println("Now testing self methods"); a.add(b); System.out.println("(1+1i)+(1+2i) = " + a); kthComplex c = new kthComplex(1.0, 1.0); kthComplex d = new kthComplex(1.0, 2.0); c.subtract(d); System.out.println("(1+1i)-(1+2i) = " + d); kthComplex e = new kthComplex(1.0, 1.0); kthComplex f = new kthComplex(1.0, 2.0); e.multiply(f); System.out.println("(1+1i)*(1+2i) = " + e); kthComplex g = new kthComplex(1.0, 1.0); kthComplex h = new kthComplex(1.0, 2.0); g.divide(h); System.out.println("(1+1i)/(1+2i) = " + g); } }