
import java.util.*;

/** Complex numbers. Basic operations. */
public class Complex {

   // TODO!!! Your fields here

   /** Constructor from the pair of double values.
    * @param r real part
    * @param i imaginary part
    */
   public Complex (double r, double i) {
      // TODO!!!
   }

   /** Real part of the complex number.
    * @return real part
    */
   public double getRe() {
      return 0.; // TODO!!!
   }

   /** Imaginary part of the complex number. 
    * @return imaginary part
    */
   public double getIm() {
      return 0.; // TODO!!!
   }

   /** Conversion of the complex number to the string.
    * @return a string of form "a+bi", "-a+bi", "a-bi" or "-a-bi" 
    * (without any brackets)
    */
   @Override
   public String toString() {
      return null; // TODO!!!
   }

   /** Conversion from the string to the complex number. 
    * Reverse to <code>toString</code> method.
    * @throws IllegalArgumentException if string s does not represent 
    *     a complex number (defined by the <code>toString</code> method)
    * @param s string of form produced by the <code>toString</code> method
    * @return a complex number represented by string s
    */
   public static Complex valueOf (String s) {
      return null; // TODO!!!
   }

   /** Clone of the complex number.
    * @return independent clone of <code>this</code>
    */
   @Override
   public Object clone() throws CloneNotSupportedException {
      return null; // TODO!!!
   }

   /** Test whether the complex number is zero. 
    * @return true if the real part and the imaginary part 
    *    are both (close to) zero
    */
   public boolean isZero() {
      return true; // TODO!!!
   }

   /** Conjugate of the complex number. Expressed by the formula 
    *     conjugate(a+bi) = a-bi
    * @return conjugate of <code>this</code>
    */
   public Complex conjugate() {
      return null; // TODO!!!
   }

   /** Opposite of the complex number. Expressed by the formula 
    *    opposite(a+bi) = -a-bi
    * @return complex number <code>-this</code>
    */
   public Complex opposite() {
      return null; // TODO!!!
   }

   /** Sum of complex numbers. Expressed by the formula 
    *    (a+bi) + (c+di) = (a+c) + (b+d)i
    * @param k addend (c+di)
    * @return complex number <code>this+k</code>
    */
   public Complex plus (Complex k) {
      return null; // TODO!!!
   }

   /** Product of complex numbers. Expressed by the formula
    *  (a+bi) * (c+di) = (ac-bd) + (ad+bc)i
    * @param k factor (c+di)
    * @return complex number <code>this*k</code>
    */
   public Complex times (Complex k) {
      return null; // TODO!!!
   }

   /** Inverse of the complex number. Expressed by the formula
    *     1/(a+bi) = a/(a*a+b*b) + ((-b)/(a*a+b*b))i
    * @return complex number <code>1/this</code>
    */
   public Complex inverse() {
      return null; // TODO!!!
   }

   /** Difference of complex numbers. Expressed as addition to the opposite.
    * @param k subtrahend
    * @return complex number <code>this-k</code>
    */
   public Complex minus (Complex k) {
      return null; // TODO!!!
   }

   /** Quotient of complex numbers. Expressed as multiplication to the inverse.
    * @param k divisor
    * @return complex number <code>this/k</code>
    */
   public Complex divideBy (Complex k) {
      return null; // TODO!!!
   }

   /** Equality test of complex numbers. Difference of equal numbers
    *     is (close to) zero.
    * @param ko second complex number
    * @return logical value of the expression <code>this.equals(ko)</code>
    */
   @Override
   public boolean equals (Object ko) {
      return false; // TODO!!!
   }

   /** Module of the complex number. Expressed by the formula 
    *     module(a+bi) = Math.sqrt(a*a+b*b)
    * @return module of <code>this</code> (module is a real number)
    */
   public double module() {
      return 0.; // TODO!!!
   }

   /** Polar angle of the complex number (principal value) in radians.
    * Defined by the connection  a+bi = m*cos(p) + (m*sin(p))i ,
    *    where m is the module and p is the polar angle of complex number a+bi.
    *    In Java p=Math.atan2(b,a)
    * @return polar angle p of <code>this</code> (in radians)
    */
   public double angle() {
      return 0.; // TODO!!!
   }

   /** Main method for testing purposes. 
    * @param arg command line parameters
    */
   public static void main (String[] arg) {
      // TODO!!! Your tests here!

      Complex arv1 = new Complex (-1., 1.);
      if (arg.length > 0)
         arv1 = valueOf (arg[0]);
      System.out.println ("first: " + arv1.toString());
      System.out.println ("real: " + arv1.getRe());
      System.out.println ("imag: " + arv1.getIm());
      System.out.println ("isZero: " + arv1.isZero());
      System.out.println ("conjugate: " + arv1.conjugate());
      System.out.println ("opposite: " + arv1.opposite());
      Complex res = null;
      try {
         res = (Complex)arv1.clone();
      } catch (CloneNotSupportedException e) {};
      System.out.println ("clone equals to original: " + res.equals (arv1));
      System.out.println ("clone is not the same object: " + (res!=arv1));
      res = valueOf (arv1.toString());
      System.out.println ("string conversion equals to original: " 
         + res.equals (arv1));
      Complex arv2 = new Complex (1., -2.);
      if (arg.length > 1)
         arv2 = valueOf (arg[1]);
      System.out.println ("second: " + arv2.toString());
      System.out.println ("equals: " + arv1.equals (arv2));
      res = arv1.plus (arv2);
      System.out.println ("plus: " + res);
      System.out.println ("times: " + arv1.times (arv2));
      System.out.println ("minus: " + arv1.minus (arv2));
      double mm = arv1.module();
      System.out.println ("module: " + mm);
      double nn = arv1.angle();
      System.out.println ("angle: " + nn);
      System.out.println ("back from polar: " + new Complex (mm*Math.cos (nn),
         mm*Math.sin (nn)));
      System.out.println ("inverse: " + arv1.inverse());
      System.out.println ("divideBy: " + arv1.divideBy (arv2));
   }

}

