public class ComplexAfter {

  public static void main(String args[]) {

    Complex x = new Complex (1.0, 2.0);
    Complex y = new Complex (3.0, 4.0);

    System.out.println (y.abs());
    
    x.conjugate ();
    x.print ();
    y.print ();
    
    Complex s = x.add (y);
    s.print ();
  }
}

class Complex
{
  double real, imag;

  public Complex () {
    this.real = 0.0;  this.imag = 0.0;
  }

  public Complex (double real, double imag) {
    this.real = real;  this.imag = imag;
  }

  public void print () {
    System.out.println (real + " + " + imag + "i");
  }

  public void conjugate () {
    imag = -imag;
  }

  // abs is a function that returns a primitive
  public double abs () {
    return Math.sqrt (real * real + imag * imag);
  }

  // add is a function that returns a new Complex object
  public Complex add (Complex b) {
    return new Complex (this.real + b.real, this.imag + b.imag);
  }
}


