Browse Source

changed the equals methode to match java standart

featureKomplexNumberCalculator
Lukas Reichwein 5 years ago
parent
commit
99ca7b9d45
  1. 8
      src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java

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

@ -48,9 +48,11 @@ public class ComplexNumber {
* @param complexNumber The number wich gets compared with this Instance * @param complexNumber The number wich gets compared with this Instance
* @return True if the complex Numbers are Equal * @return True if the complex Numbers are Equal
*/ */
public boolean equals(ComplexNumber complexNumber) {
if (this.realPart.equals(complexNumber.realPart) && this.imaginaryPart.equals(complexNumber.imaginaryPart)) {
return true;
@Override
public boolean equals(Object complexNumber) {
if (complexNumber instanceof ComplexNumber){
ComplexNumber that = (ComplexNumber) complexNumber;
return this.realPart.equals(that.realPart) && this.imaginaryPart.equals(that.imaginaryPart);
} else { } else {
return false; return false;
} }

Loading…
Cancel
Save