Ver código fonte

Add hashCode method to starter solution

Jack Mustacato 8 anos atrás
pai
commit
40c165104c

+ 10
- 0
exercises/rational-numbers/src/main/java/Rational.java Ver arquivo

27
         return this.getNumerator() == other.getNumerator()
27
         return this.getNumerator() == other.getNumerator()
28
             && this.getDenominator() == other.getDenominator();
28
             && this.getDenominator() == other.getDenominator();
29
     }
29
     }
30
+
31
+    @Override
32
+    public int hashCode() {
33
+        int prime = 31;
34
+        int result = 1;
35
+        result = prime * result + this.getNumerator();
36
+        result = prime * result + this.getDenominator();
37
+
38
+        return result;
39
+    }
30
 }
40
 }