Lab - Junit
Implement a Java class gInt (Gaussian Integer) and write a JUnit test suite. Use Ant to bring it all together.
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:
gInt( int r ) - c'tor. Note, a real # is a complex number
gInt( int r, int i ) - c'tor
Note: No default c'tor. All objects must be initialised
int real() - the real part of the number
int imag() - the imaginary part of the number
gInt add( gint rhs ) - return a new gInt, the sum of this and rhs. Note, the object receiving this message is not modified.
gInt multiply( gint rhs ) - return a new gInt, the product of this and rhs. Note, the object receiving this message is not modified.
float norm() - return the L2-norm of the integer (the distance from the origin). The object is not modified.
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".
Provide a build file that compiles your classes and runs the tests. The default target will be test, which depends on the compile target.
Use the example in this lab directory (Java/Junit) for guidance
One method at a time!
Write the comments (pre- and post-conditions) for each method first
Then write the corresponding test for that method
Then you actually implement the method
Submit the following files:
[url removed, login to view] - the gInt class
[url removed, login to view] - the TestCase for gInt
[url removed, login to view] - the Ant build file
README (opt.) - if you have anything to tell me before I grade the lab
3 freelancers estão ofertando em média $23 para este trabalho
Hi I have already created the project with all the requirement : Java class to implement GaussianInteger Junit Test class GaussianInteger Ant Build file.