From 99ca7b9d45ae6682653e82febca27f332d476d68 Mon Sep 17 00:00:00 2001 From: Lukas Reichwein Date: Tue, 16 Jul 2019 19:20:35 +0200 Subject: [PATCH] changed the equals methode to match java standart --- .../java/com/ugsbo/complexnumcalc/ComplexNumber.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java b/src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java index ade991d..b05fea2 100644 --- a/src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java +++ b/src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java @@ -48,12 +48,14 @@ public class ComplexNumber { * @param complexNumber The number wich gets compared with this Instance * @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 { return false; - } + } } /**