CS U370 Assignment #2 Section: Clinger Assigned: Tuesday, 13 January 2009 Due: Tuesday, 20 January 2009 The purpose of this assignment is: * To review the composite pattern * To continue our study of abstraction-based software design by implementing a second algebraic specification * To continue our review of static methods * To give another example of factory methods for creating new objects * To prepare for an assignment that covers black-box testing. You will complete an implementation in Java of the Dependency ADT that is 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 Dependency.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 how well you follow the procedure above for submitting your work. Late assignments may be discounted, and very late assignments may be discarded. -------------------------------------------------- Your assignment is to write the code for a single file, Dependency.java, that implements the specification below. For this assignment, no test program is provided; you should write a test program yourself. A future assignment will require you to test implementations of the Dependency ADT that were written by other students. As part of that assignment, other students will test the code you submit for this assignment. -------------------------------------------------- Specification of the Dependency ADT. The Dependency ADT shall be implemented in Java, and will be tested using Sun's Java 2 Runtime Environment, Standard Edition, version 1.6.0. The code for this implementation will be in the default package, and shall define a public class named Dependency. That class shall provide the following public static methods: Signature: Dependency.create : Refreshable * Refreshable -> Dependency Dependency.first : Dependency -> Refreshable Dependency.second : Dependency -> Refreshable Dependency.isOkay : Dependency -> boolean Dependency.first (Dependency.create (r1, r2)) = r1 Dependency.second (Dependency.create (r1, r2)) = r2 Dependency.isOkay (Dependency.create (r1, r2)) = Refreshable.era(r1) <= Refreshable.era(r2) Values of the Dependency ADT shall also implement the public dynamic methods equals(Object) and hashCode() such that If v1 and v2 are values of the Dependency ADT, then v1.equals(v2) if and only if Dependency.first(v1).equals(Dependency.first(v2)) and Dependency.second(v1).equals(Dependency.second(v2)) If v1 is a value of the Dependency ADT, but x is not, then v1.equals(x) returns false. If v1 and v2 are values of the Dependency ADT, and v1.equals(v2) then v1.hashCode() == v2.hashCode(). --------------------------------------------------