/** * Returns <tt>true</tt> if and only if this state is considered equal to the given object. In * particular, equality is defined to hold if the given object is also a <tt>State</tt> object, if * it is associated with the same <tt>Puzzle</tt> object, and if the cars in both states are in * the identical positions. This method overrides <tt>Object.equals</tt>. */ public boolean equals(Object o) { State s; try { s = (State) o; } catch (ClassCastException e) { return false; } if (hashcode != s.hashcode || !puzzle.equals(s.puzzle)) return false; for (int i = 0; i < varPos.length; i++) if (varPos[i] != s.varPos[i]) return false; return true; }