Lab - Junit

Implement a Java class gInt (Gaussian Integer) and write a JUnit test suite. Use Ant to bring it all together.

Background

A Gaussian integer is a number of the form a + b i, where a (the real part), b (the imaginary part) are integers, and i is the square root of -1.

They are added in a very normal way. (a + b i) + (c + d i) = (a+c) + (b+d) i.

Multiplication should also look familiar. (a + b i) * (c + d i) = (ac-bd) + (ad+bc) i.


The gInt class

This class should have, at a minimum, the following behavior:


Your test framework - the gIntTest class

You can name the methods how you'd like (as long as they're good names). You will provide a test for each method, above (but not for the c'tors).

Remember, a single test does not go far towards being reliable. Consider all of the preconditions and postconditions! They must be tested too, not simply that you "got the right answer".


Ant

Provide a build file that compiles your classes and runs the tests. The default target will be test, which depends on the compile target.


Misc


Submission

Submit the following files: