package class7_2_Complex; /** * A complex number. * * This number consists of two parts, the real part * (an ordinary number with a decimal part) * and the imaginary part (an ordinary number * multiplied by sqrt(-1). * * The full number is * real + imag * i * * where i = sqrt(-1) */ public class Complex { private double real; private double imag; /** * Create a complex zero. * Both real and imaginary parts are zero */ public Complex() { this(0,0); // DIFFERENT FROM: new Complex(0,0) <- DOESN'T WORK } /** * Create a real number. The imaginary part is zero. * @param real The value of the real number */ public Complex(double real) { // Exercise: ??? What goes here ??? } /** * Create a complex number * @param real The real part of the number * @param imag The imaginary part of the number */ public Complex(double real, double imag) { this.real = real; this.imag = imag; } }