@Test
 public void canConvertNegativeImaginaryPartToString() {
   ComplexNumber z = new ComplexNumber(1, -1);
   assertEquals("1.0 - 1.0i", z.toString());
 }
 @Test
 public void canConvertNegativeRealPartToString() {
   ComplexNumber z = new ComplexNumber(-1, 1);
   assertEquals("-1.0 + 1.0i", z.toString());
 }
 @Test
 public void canConvertScientificFormatToString() {
   ComplexNumber z = new ComplexNumber(1, 1.2456e-2);
   assertEquals("1.0 + 0.01i", z.toString());
 }
 @Test
 public void canConvertFloatingComplexNumberToString() {
   ComplexNumber z = new ComplexNumber(3.14, 2);
   assertEquals("3.14 + 2.0i", z.toString());
 }
 @Test
 public void canConvertToString() {
   ComplexNumber z = new ComplexNumber(1, 2);
   assertEquals("1.0 + 2.0i", z.toString());
 }
Ejemplo n.º 6
0
 /**
  * Returns the complex plane currently being used.
  *
  * @return complex plan currently being used.
  */
 private String complexPlane() {
   ComplexNumber C1 = new ComplexNumber(new RealNumber(currWXMin), new RealNumber(currWYMin));
   ComplexNumber C2 = new ComplexNumber(new RealNumber(currWXMax), new RealNumber(currWYMax));
   return "< " + C1.toString() + ", " + C2.toString() + " >";
 }