Goal:
Preconditions, Contracts
Consider the Set interface. We discussed the precondition for this interface during in-class exercise 4.
Write client code for a HashSet
object that violates the precondition.
Continue with the client code until
you observe outputs
that would be clearly incorrect,
except for the fact that the precondition was violated.
Document your exercise so that a neutral third party
(without expertise from this class) would be able to
understand what is happening.
In particular, explain what
hashCode()
and equals()
have to do with
the anomalies you observe. (You might have to revisit
your knowledge from CS 310 to do this.)
Grading: