CS U370 Assignment #2 Section: Clinger Assigned: Tuesday, 26 September 2006 Due: Tuesday, 3 October 2006 The purpose of this assignment is: * To implement an algrebraic specification * To use packages in Java * To introduce enum types * To expose enum constants as part of a class's interface * To use java.util.Date * To implement the canonical methods equals() and toString() You will complete an implementation in Java of the Issue class specified below. Collaboration between students is forbidden on this assignment. You are responsible for keeping your code hidden from all other students. Turn in your work on this assignment before 10 pm on the due date by sending electronic mail to: will@ccs.neu.edu with subject CSU370 assignment 2 and a body that consists of nothing but your Issue.java file. That file should begin with a block comment that lists 1. Your name, as you want the instructor to write it. 2. Your email address. 3. Any remarks that you wish to make to the instructor. Part of your grade will depend on the quality and correctness of your code, part will depend on the readability of your code (comments and indentation), and part will depend on your following the procedure above for submitting your work. Late assignments may be discounted, and very late assignments may be discarded. -------------------------------------------------- Note: This assignment is based on the part of the Trac source code and project management system that tracks issues (usually bugs) within a software project. For an example of Trac, you can go to: http://larceny.ccs.neu.edu/trac/ Note: Issue.java must be part of the project package. -------------------------------------------------- Specification of the Issue class. The Issue class shall be implemented in Java, and will be tested using Sun's Java 2 Runtime Environment, Standard Edition, version 5.0. The code for this implementation will be in the project package, and shall define a public class named Issue, which provides the following public methods, which are specified below. Signature: // Public constants, to be located within the Issue class. public static enum Kind { DEFECT, ENHANCEMENT, ISSUE } public static enum Status { NEW, ASSIGNED, CLOSED } public static enum Priority { TRIVIAL, MINOR, MAJOR, CRITICAL } // Creators, to be located within the Issue class. public static Issue create(Kind, Status, Priority, java.util.Date, String, String); public static Issue create(Kind, String, String); public static Issue create(String, String); // Accessors public Kind getKind(); public Status getStatus(); public Priority getPriority(); public java.util.Date getTargetDate(); public String getOwner(); public String getSummary(); // Predicates public boolean isHigherPriorityThan(Issue) // Canonical Methods public String toString(); Specification of behavior: Issue.create(k, s1, s2) = Issue.create(k, Issue.Status.NEW, Issue.Priority.MINOR, d, s1, s2) where d = current time + 180 days Issue.create(s1, s2) = Issue.create(Issue.Kind.ISSUE, s1, s2) Issue.create(k, stat, pri, d, s1, s2).getKind() = k Issue.create(k, stat, pri, d, s1, s2).getStatus() = stat Issue.create(k, stat, pri, d, s1, s2).getPriority() = pri Issue.create(k, stat, pri, d, s1, s2).getTargetDate() = d Issue.create(k, stat, pri, d, s1, s2).getOwner() = s1 Issue.create(k, stat, pri, d, s1, s2).getSummary() = s2 Issue.create(k, stat, pri, d, s1, s2).isHigherPriorityThan(obj) = true if pri.ordinal() > obj.getPriority().ordinal() false otherwise Issue.create(k, stat, pri, d, s1, s2).toString() = if a = Issue.Kind.DEFECT then "Issue: Defect: " + s2 + " To be resolved by: " + d if a = Issue.Kind.ENHANCEMENT then "Issue: Enhancement: " + s2 + " To be resolved by: " + d otherwise "Issue: " + s2 + " To be resolved by: " + d Note 1: The owner and summary arguments to Issue.create() cannot be longer than 60 characters Note 2: The java.util.Date argument to create must be later than the time at which create is called. If any of these conditions are violated, an IllegalArgumentException should be thrown with an appropriate message.