@@ -29,9 +29,7 @@ public void noObjectShouldBeEqualToNull() {
2929 }
3030
3131 static class Car {
32- @ SuppressWarnings ("unused" )
3332 private String name = "" ;
34- @ SuppressWarnings ("unused" )
3533 private int horsepower = 0 ;
3634
3735 public Car (String s , int p ) {
@@ -49,7 +47,7 @@ public boolean equals(Object other) {
4947
5048 @ Override
5149 public int hashCode () {
52- // see koan ownHashCode
50+ // @ see http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#hashCode()
5351 return super .hashCode ();
5452 }
5553 }
@@ -58,7 +56,7 @@ public int hashCode() {
5856 public void equalForOwnObjects () {
5957 Car car1 = new Car ("Beetle" , 50 );
6058 Car car2 = new Car ("Beetle" , 50 );
61- // See line 37 for the task you have to solve
59+ // @see Car.equals (around line 45) for the place to solve this
6260 assertEquals (car1 .equals (car2 ), true );
6361 assertEquals (car2 .equals (car1 ), true );
6462 }
@@ -67,22 +65,22 @@ public void equalForOwnObjects() {
6765 public void unequalForOwnObjects () {
6866 Car car1 = new Car ("Beetle" , 50 );
6967 Car car2 = new Car ("Porsche" , 300 );
70- // See line 37 for the task you have to solve
68+ // @see Car.equals (around line 45) for the place to solve this
7169 assertEquals (car1 .equals (car2 ), false );
7270 }
7371
7472 @ Koan
7573 public void unequalForOwnObjectsWithDifferentType () {
7674 Car car1 = new Car ("Beetle" , 50 );
7775 String s = "foo" ;
78- // See line 37 for the task you have to solve
76+ // @see Car.equals (around line 45) for the place to solve this
7977 assertEquals (car1 .equals (s ), false );
8078 }
8179
8280 @ Koan
8381 public void equalNullForOwnObjects () {
8482 Car car1 = new Car ("Beetle" , 50 );
85- // See line 37 for the task you have to solve
83+ // @see Car.equals (around line 45) for the place to solve this
8684 assertEquals (car1 .equals (null ), false );
8785 }
8886
@@ -93,7 +91,7 @@ public void ownHashCode() {
9391 // Read the hash code contract to figure out why
9492 // http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#hashCode()
9593
96- // Implement a hash code version in line 47 so that the following assertions pass
94+ // Implement Car.hashCode around line 51 so that the following assertions pass
9795 Car car1 = new Car ("Beetle" , 50 );
9896 Car car2 = new Car ("Beetle" , 50 );
9997 assertEquals (car1 .equals (car2 ), true );
@@ -123,8 +121,8 @@ public void ownHashCodeImplementationPartTwo() {
123121 Chicken chicken2 = new Chicken ();
124122 assertEquals (chicken1 .equals (chicken2 ), __ );
125123 assertEquals (chicken1 .hashCode () == chicken2 .hashCode (), __ );
126- // Does this still fit the hashCode contract? Why?
127- // If it's valid why is this still not a good idea?
124+ // Does this still fit the hashCode contract? Why (not) ?
125+ // Fix the Chicken class to correct this.
128126 }
129127
130128}
0 commit comments