public static void main(String args[]) { // use the first constructor Complex x = new Complex(); x.real = 1.0; x.imag = 2.0; // use the second constructor Complex y = new Complex(3.0, 4.0); System.out.println(abs(y)); conjugate(x); printComplex(x); printComplex(y); Complex s = add(x, y); printComplex(s); }
// conjugate is a modifier public static void conjugate(Complex c) { c.imag = -c.imag; }