diff --git a/src/main/java/io/github/auberonedu/equalsLivecode/Centroid.java b/src/main/java/io/github/auberonedu/equalsLivecode/Centroid.java index b0e343a..a0877b8 100644 --- a/src/main/java/io/github/auberonedu/equalsLivecode/Centroid.java +++ b/src/main/java/io/github/auberonedu/equalsLivecode/Centroid.java @@ -22,4 +22,46 @@ public int getC() { public String getName() { return name; } + + public int HashCode() { + final int prime = 25; + int result = 1; + result = prime+result+c; + result = prime+result+r; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this==obj) return true; + if (obj==null) return false; + if (getClass()!=obj.getClass()) return false; + Centroid o = (Centroid) obj; + if (r!= o.r) return false; + if (c!= o.c) return false; + return true; + } + + // @Override + // public boolean equals(Object o) { + // if (o==null) return false; + // if (!this.getClass().equals(o.getClass())) { + // return false; + // } + + // Centroid other = (Centroid) o; + // if (this.r != other.r) return false; + // if (this.c != other.c) return false; + + // if (this.name==null) { + // if (other.name==null) { + // return true; + // } + // else { + // return false; + // } + // } + // if (!this.name.equals(other.name)) return false; + // return true; + // } } diff --git a/src/main/java/io/github/auberonedu/equalsLivecode/NameCentroid.java b/src/main/java/io/github/auberonedu/equalsLivecode/NameCentroid.java new file mode 100644 index 0000000..2f9179c --- /dev/null +++ b/src/main/java/io/github/auberonedu/equalsLivecode/NameCentroid.java @@ -0,0 +1,4 @@ +package io.github.auberonedu.equalsLivecode; + +public record NameCentroid(String name, int r, int c) { +} \ No newline at end of file