Subtraction
Write the test:
public void testSubtract() {
Complex z1 = new Complex(1, 1);
Complex z2 = new Complex(1, 1);
Complex z3 = z1.subtract(z2);
assertEquals(0, z3.getRealPart(), tolerance);
assertEquals(0, z3.getImaginaryPart(), tolerance);
}
Implement the feature:
public Complex subtract(Complex z) {
// ???? Auto-generated method stub
return null;
}
Debug until the test passes:
public Complex subtract(Complex z) {
return new Complex(this.real - z.real, this.imaginary - z.imaginary);
}