COM 1204 Assignment #1. Due: Tuesday, 9 April 2002 You will complete an implementation in Java of the SeqInt ADT that was specified in class. (Part of this specification is reproduced below.) Class files compiled from your code may be used by other students in a future assignment. Collaboration between students is forbidden on this assignment. You are responsible for keeping your code hidden from all other students. Part of your grade will be determined by how well you hide your code, part of your grade will be determined by how well you follow the instructions for submitting your code, part of your grade will depend upon the correctness of your code, and part of your grade will depend upon the readability of your code (e.g. formatting and comments). Turn in your work on this assignment before 4 pm on the due date by sending electronic mail to will@ccs.neu.edu with subject COM 1204 assignment #1 and a body that consists of nothing but your SeqIntSingleton.java file. That file should begin with a block comment that lists 1. Your name, as you want the instructor to write it. 2. Any remarks that you wish to make to the instructor. Late assignments may be discounted, and very late assignments may be discarded. -------------------------------------------------- Your assignment is to write the code for a single file, SeqIntSingleton.java, that defines SeqIntSingleton as a concrete subclass of the abstract class SeqInt, and completes the implementation of the SeqInt ADT that is provided by the code in /course/com1204/.www/will/Assignments/A1 This code is written using the instructor's recipe for translating an algebraic specification of an immutable abstract data type into Java. For this assignment, you shall not modify any files except for SeqIntSingleton.java. Note that the directory above contains a small test program. For reference, the client's view of the SeqInt ADT appears below. -------------------------------------------------- Specification of the SeqInt ADT. SeqInt is an immutable abstract data type. Its operations shall have no side effects. The SeqInt ADT shall be implemented in Java, and will be tested using Sun's Java 2 Runtime Environment, Standard Edition. The code for this implementation shall be in the default package, and shall define a public class named SeqInt that defines the following public static methods, which are specified below. Signature: public static SeqInt empty(); public static SeqInt singleton (int); public static SeqInt concat (SeqInt, SeqInt); public static boolean isEmpty (SeqInt); public static int length (SeqInt); public static int at (SeqInt, int); Algebraic specification: isEmpty (empty()) = true isEmpty (singleton (x)) = false isEmpty (concat (s1, s2)) = isEmpty (s1) && isEmpty (s2) length (empty()) = 0 length (singleton (x)) = 1 length (concat (s1, s2)) = length (s1) + length (s2) at (singleton (x), 0) = x at (concat (s1, s2), i) = at (s1, i) if i < length (s1) at (concat (s1, s2), i) = at (s2, i - length (s1)) otherwise --------------------------------------------------