SWE 619 In Class Exercise Number 1B
September 5, 2017


Consider the following specification and implementation:


public static List<Integer> tail (List<Integer> list) {

   // REQUIRES: ???
   // EFFECTS:  ???

   List<Integer> result = new ArrayList<Integer>list);
   result.remove(0);
   return result;
}
  1. What does the implementation of tail do in each of the following cases?
    • list = null

    • list = []

    • list = [1]

    • list = [1, 2, 3]

  2. Write a partial specification that matches the "happy path" part of the implementation's behavior.

  3. Rewrite the specification to be total. Use Bloch's standard exceptions.