CS U370 Assignment #5 Section: Clinger Assigned: Tuesday, 10 February 2009 Corrected: Sunday, 15 February 2009 (see ! in column 79) Due: Tuesday, 17 February 2009 The purpose of this assignment is: * To use the standard recipe for a more complex specification * To adapt the recipe for dynamic methods * To introduce topological sorting You will extend the Dependencies ADT that was specified in assignment 3 by implementing the public dynamic methods 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 5 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 (including its implementation of the specification given in assignment 3 as well as the specification below), 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 as well as the specification of assignment 3. For this assignment, no test program is provided; you should write a test program yourself. -------------------------------------------------- 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 all of the methods specified in assignment 3. In addition, that class shall provide the following public dynamic methods: Signature: maximal : -> Refreshable isMaximal : Refreshable -> boolean relevantTo : Refreshable -> Dependencies irrelevantTo : Refreshable -> Dependencies ! without : Dependency -> Dependencies concatenate : Dependencies -> Dependencies todo : -> Dependencies Dependencies.adjoin(Dependency.create(r1, r2), s).maximal() = r2 if s.isMaximal(r2) Dependencies.adjoin(Dependency.create(r1, r2), s).maximal() = s.maximal() if not (s.isMaximal(r2)) Dependencies.none().isMaximal(r) = true Dependencies.adjoin(Dependency.create(r1, r2), s).isMaximal(r) = (not r1.equals(r)) and s.isMaximal(r) Dependencies.none().relevantTo(r) = Dependencies.none() Dependencies.adjoin(Dependency.create(r1, r2), s).relevantTo(r) = Dependencies.adjoin(Dependency.create(r1, r2), s.relevantTo(r)) if r1.equals(r) or r2.equals(r) Dependencies.adjoin(Dependency.create(r1, r2), s).relevantTo(r) = s.relevantTo(r) if (not r1.equals(r)) and (not r2.equals(r)) Dependencies.none().irrelevantTo(r) = Dependencies.none() ! Dependencies.adjoin(Dependency.create(r1, r2), s).irrelevantTo(r) = s.irrelevantTo(r) if r1.equals(r) or r2.equals(r) Dependencies.adjoin(Dependency.create(r1, r2), s).irrelevantTo(r) = Dependencies.adjoin(Dependency.create(r1, r2), s.irrelevantTo(r)) if (not r1.equals(r)) and (not r2.equals(r)) Dependencies.none().without(d) = Dependencies.none() Dependencies.adjoin(d, s).without(d1) = s.without(d1) if d.equals(d1) Dependencies.adjoin(d, s).without(d1) = Dependencies.adjoin(d, s.without(d1)) if not d.equals(d1) Dependencies.none().concatenate(s2) = s2 Dependencies.adjoin(d, s).concatenate(s2) = Dependencies.adjoin(d, s.concatenate(s2)) Dependencies.none().todo() = Dependencies.none() Dependencies.adjoin(d, s).todo() = Dependencies.adjoin(d, s) .irrelevantTo(Dependencies.adjoin(d, s).maximal()) .todo() .concatenate(Dependencies.adjoin(d, s) .relevantTo(Dependencies.adjoin(d, s).maximal())) --------------------------------------------------