From 8de023c060582ddbf4ef787daee50d3882a2562b Mon Sep 17 00:00:00 2001
From: fefe <hofer.francois.01@gmail.com>
Date: Fri, 22 Nov 2019 12:00:57 +0100
Subject: [PATCH] Edited equals() overrided method of vectors -> why tests
 didn't work

---
 src/main/java/ch/hepia/numeric/Vector.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/main/java/ch/hepia/numeric/Vector.java b/src/main/java/ch/hepia/numeric/Vector.java
index b8f545b..81649ab 100644
--- a/src/main/java/ch/hepia/numeric/Vector.java
+++ b/src/main/java/ch/hepia/numeric/Vector.java
@@ -191,6 +191,19 @@ final public class Vector {
 
     @Override
     public boolean equals(Object obj) {
-        throw new UnsupportedOperationException("This feature isn't implemented yet");
+        if (this == obj) return true;
+        if (obj == null || obj.getClass() != this.getClass()) {
+            return false;
+        }
+        Vector vec = (Vector) obj;
+        if (vec.len() != this.len()){
+            return false;
+        }
+        for (int i=0;i<vec.len();i++){
+            if (Double.compare(vec.getValues().get(i), this.getValues().get(i))!=0){
+                return false;
+            }
+        }
+        return true;
     }
 }
\ No newline at end of file
-- 
GitLab