public class Complex { private double real, // the real part imag; // the imaginary public Complex(double r, double i) { this.real = r; this.imag = i; } public Complex(Complex c) { this.real = c.getReal(); this.imag = c.getImag(); } public double getReal() { return this.real; } public double getImag() { return this.imag; } public void add(Complex c) { this.real += c.getReal(); this.imag += c.getImag(); } public Complex multiply(Complex c) { double temp = this.real * c.getReal() - this.imag * c.getImag(); this.imag = this.real * c.getImag() + this.imag * c.getReal(); this.real = temp; return this; } public double sizeSquared() { return this.real*this.real + this.imag*this.imag; } }