CS U370 Assignment #3 Section: Clinger Assigned: Tuesday, 20 January 2009 Corrected: Sunday, 25 January 2009 (see ! in column 79) Due: Tuesday, 27 January 2009 The purpose of this assignment is: * To use the standard recipe * To continue our study of abstraction-based software design by implementing a third algebraic specification * To continue our review of static methods * To give a third example of factory methods for creating new objects You will complete an implementation in Java of the Dependencies 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 3 and a body that consists of nothing but your Dependencies.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, Dependencies.java, that implements the specification below. For this assignment, an inadequate test program is provided at /course/csu370wc/Assignments/A3/TestDependencies.java . You will need to supplement that test program with your own tests. -------------------------------------------------- Specification of the Dependencies ADT. Like the Refreshable and Dependency abstract data types, the Dependencies abstract data type is immutable. The Dependencies 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 Dependencies. That class shall provide the following public static methods: Signature: Dependencies.none : -> Dependencies Dependencies.adjoin : Dependency * Dependencies -> Dependencies Dependencies.absent : Dependencies -> boolean Dependencies.first : Dependencies -> Dependency Dependencies.rest : Dependencies -> Dependencies ! Dependencies.okay : Dependencies -> boolean Dependencies.absent (Dependencies.none()) = true Dependencies.absent (Dependencies.adjoin (d, s)) = false Dependencies.first (Dependencies.adjoin (d, s)) = d Dependencies.rest (Dependencies.adjoin (d, s)) = s Dependencies.okay (Dependencies.none()) = true Dependencies.okay (Dependencies.adjoin (d, s)) = Dependency.isOkay(d) && Dependencies.okay(s) Values of the Dependencies ADT shall also implement the public dynamic methods equals(Object) and hashCode() such that If v1 and v2 are values of the Dependencies ADT, then v1.equals(v2) if and only if (Dependencies.absent(v1) and Dependencies.absent(v2)) or ((not Dependencies.absent(v1)) and (not Dependencies.absent(v2)) and Dependencies.first(v1).equals(Dependencies.first(v2)) and Dendencies.rest(v1).equals(Dependencies.rest(v2))) If v1 is a value of the Dependencies ADT, but x is not, then v1.equals(x) returns false. If v1 and v2 are values of the Dependencies ADT, and v1.equals(v2) then v1.hashCode() == v2.hashCode(). --------------------------------------------------