Complete Specifications for the Complex Class

What is an API? It is an application programming interface. Essentially, it is a new data type along with the documentation needed to use it properly. We will use finality to make these objects immutible.

What are Complex Numbers? Open complex.pdf. It explains all. I will do some discussion in class, too.

This is your chance to create an API You will create a class for doing computation with complex numbers. It will have all features listed here. Use the ideas from the BigFraction case study. Your final product should have a similar appearance to the product in the textbook.

Tip Build this class as I build the BigFraction API. As I implement features in BigFraction, you should implement those features in Complex.java; it will help you to follow the discussion. Also, you will have a good model as to how to proceed. This project will help you to understand the whole process of creating an API.

Tip Compile early and often! Also you may insert a main method. Test your code as you go along. Even better, write test code for each method before writing the method.

Static Constants Our class will have three static constants as shown here. Initialize them in a static block.

In mathematical parlance, we use \(|z|\) for the magnitude of a complex number. Notice how this is an extension of the definition of absolute value for a real number.

For a complex number \(z = a + ib\), its argument is defined as \(\arcsin(b/|z|)\). This it the angle it makes, as a vector, with the positive real (\(x\)-axis) in the complex plane.

State Your class wlll have private state variables re and im that are doubles.

Methods Your public interface will look like this. You may add any private or other methods as you see fit.

Javadoc You will also javadoc this class so it is usable by someone who does not see your code. This is an important part of the project.

Shell Code Download the shell code on the left; there are two files Complex.java and IComplex.java. Place them in the same folder and open them with DrJava. They will compile right out of the box, since all methods bear an appropriate stub.

Do not change the contents of IComplex.java at all. Compile it and keep it in the same directory as Complex.java Do not change any of the method names or signaures in Complex.java. You may add methods to this class if you wish. Of course, you may also add private methods to do tasks behind the scenes.

Turning This In All you need turn in is the file Complex.java; I can generate anything else that is needed by compiling.