CSSE 373 Formal Methods in Specification and Design

HW10

Purpose: practice specifying classes using JML and checking specifications using ESC/Java2

  1. Keep track of how much time you spend on this assignment. Unlike previous assignments you will submit your answers by committing annotated Java files at the end of the homework.
  2. Install the Mobius PVE, create a new workspace, and a new project (with ESC/Java nature) by carefully following these instructions.
  3. Copy the following two Java class declarations into your new project:

  4. In general terms, your task is to annotate the two classes with JML specifications using the Design-by-Contract style. You’ll add:

    For this assignment, you do not need to specify assignable clauses, though you certainly may.

    1. Specify and fix the Amount class first. There are additional instructions in the comments at the beginning of that file. Note that the code has some subtle bugs in it. Part of your challenge is to determine whether your specification is wrong or the code is wrong. Your final solution should be concisely specified and correctly implemented.
    2. Next specify and fix the Bag class. Like Amount, there are additional instructions in the comments. Unlike Amount, I give you less information about what invariants should hold for the class. Use the method names and the general idea of a multi-set to come up with an appropriate specification.

    Some crucial hints:

  5. Copy your annotated Amount.java and Bag.java files to the appropriate HW folder in your individual subversion repository for this course. Add and commit them. You do not need to turn in a pdf for this assignment.
  6. Please complete the short, anonymous survey on ANGEL regarding this assignment. (I will study these surveys in detail after the conclusion of this offering of the course. If you have suggestions that you would like me to consider during this offering of the course, please tell me in person or use the separate Anonymous Suggestion Box on ANGEL.)

This assignment is based on one by Erik Poll at Radboud University Nijmegen.