SWE/CS 332 In Class Exercise # 2
August 30, 2017


Goal: Understanding Contracts

Problem 1:
Consider the Java Iterator interface. For each method, identify all preconditions and postconditions. For each precondition, identify a specific input that violates the precondition. For each postcondition, identify an input specific to that postcondition.

Problem 2:
Consider the (very simple) problem of finding a (possibly non-existant) common element in two collections.

  1. Write an example "happy-path" use of this functionality.

  2. What are possible (types of) collections?

  3. What are possible (types of) return values?

  4. What are possible preconditions?

  5. What are possible postconditions?