Browse Source

removed a typo and added documentation to the absoluteValueOf function

featureKomplexNumberCalculator
Lukas Reichwein 5 years ago
parent
commit
457af8fd1d
  1. 4
      src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java
  2. 2
      src/test/java/com/ugsbo/complexnumcalc/AbsoluteValueOfComplexNumbersTest.java

4
src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java

@ -128,6 +128,10 @@ public class ComplexNumber {
return qoutient; return qoutient;
} }
/**
* Calucates the absolute value of this complex number
* @return the absolute value
*/
public Double absolutValueOf(){ public Double absolutValueOf(){
Double absoluteValue = Math.sqrt(Math.pow(this.realPart, 2) + Math.pow(this.imaginaryPart, 2)) ; Double absoluteValue = Math.sqrt(Math.pow(this.realPart, 2) + Math.pow(this.imaginaryPart, 2)) ;
return absoluteValue; return absoluteValue;

2
src/test/java/com/ugsbo/complexnumcalc/AbsoluteValueOfComplexNumbersTest.java

@ -6,7 +6,7 @@ import org.junit.Test;
public class AbsoluteValueOfComplexNumbersTest { public class AbsoluteValueOfComplexNumbersTest {
@Test @Test
public void TheAbsoluteValueOfAComplexNumberWithOnlyARealPart_IsNotTHeAbsoluteValueOfTheRealPart() {
public void TheAbsoluteValueOfAComplexNumberWithOnlyARealPart_IsNotTheAbsoluteValueOfTheRealPart() {
ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(4), Double.valueOf(0)); ComplexNumber complexNumber = new ComplexNumber(Double.valueOf(4), Double.valueOf(0));
Double expected = Double.valueOf(4); Double expected = Double.valueOf(4);

Loading…
Cancel
Save