Skip to content
Snippets Groups Projects
Commit 8de023c0 authored by fefe's avatar fefe
Browse files

Edited equals() overrided method of vectors -> why tests didn't work

parent 24201f89
Branches
Tags
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment