2. Derive a Class for Complex Numbers

1) Using the Eclipse tool, create a new class to represent complex numbers (called Complex). This class should be derived from the class java.lang.Number (use the java.lang API to find Number and Object). Implement all methods required and include two from java.lang.Object (toString and equals).

In addition, implement the following interface:

    public interface BasicOps {

       // Add to this number and return it as the result
       public Number addNum(Number a);

       // Subtract from this number and return it as the result
       public Number subNum(Number b);

       // Multiply to this number and return it as the result
       public Number multNum(Number a);

       // Divide this number by and return it as the result
       public Number divNum(Number b);

    }

Implement a main method and test all features (methods) of the class in it. Handle in your code for the class Complex.

2) Now implement the class Fraction. This class should represent fraction numbers (e.g. 1/3) as two integers. Likewise Complex, Fraction should be derived from Number and implement the interface BasicOps.

Implement a main method and test all features (methods) of the class in it. Handle in your code for the class Fraction.

3) Using both classes (Complex and Fraction), create a class Test with only a main method. In this method test the interaction between the two classes using the operations of the interface BasicOps, as the example below:

    BasicOps a = new Complex(2, 3);
    Number b = new Fraction(1, 3);
    Number c = a.multNum(b);
    System.out.println("Result = " + c);

Make the tests with the greatest possible number of combination. Do not forget to check if the results are correct!

Hand in your code. You used two Java mechanisms: subclassing and interfaces. When did you use each? Should Fraction be implemented as a subclass of Complex? Why?