CS 27500 - Programming Assignment 3

This assignment makes use of the files contained in this zip file. This assignment is due Tuesday, October 31.

This assignment is based on Programming Project 9 on page 249 of our textbook (but you don't need to follow any of the instructions given in that project).

In the zip file hw3.zip there are Java files IntSeq.java and IntLinkedSeq.java and their Javadoc html files, IntSeq.html and IntLinkedSeq.html. In this assignment you will complete the source file IntLinkedSeq.java so that it implements the interface specified in IntSeq.java, IntSeq.html and IntLinkedSeq.html.

The IntLinkedSeq abstract data type is similar to the IntLinkedBag abstract data type, so some of the implementation of IntLinkedSeq.java is similar to the equivalent implementation of IntLinkedBag.java. The main difference between the two data types is that a sequence "remembers" the order of all its elements, but a bag does not maintain any information about the order of its elements. Also, the sequence interface contains a few new methods that are not equivalent to any method from the bag interface.

One big difference between your implementation of the IntLinkedSeq interface and the textbook's implementation of the IntLinkedBag interface is that in this assignment you must use a simpler definition of the IntNode interface. In the zip file hw3.zip there is a Java file, IntNode.java that implements a different version of IntNode from the one in the book. The version of IntNode in the zip file is designed to separate the responsibilities of a node object from the responsibilities of the abstract data type being built with the nodes. Do not make any changes to the file IntNode.java.

Probably the hardest part of this assignment is the two methods addAfter() and addBefore(). There are several cases to consider within each method - does the sequence have a "current" element, is the sequence empty, are you positioned at the beginning or the end of the sequence? Be sure to test these two methods carefully (and draw pictures!).

While you are doing this assignment, try to "use the interface to implement the interface". That is, try to implement methods in the interface by using more basic, or fundamental, methods from the interface. You need to think about which methods are the most basic. Then implement those methods first, and then start building other methods (as much as possible) from the basic ones.

In the zip file hw3.zip there are several Java files, TestIntLinkedSeq_ver*.java, that you can use to test your implementation of the IntLinkedSeq public interface. You should also write your own test code. Every time you complete a method in the IntLinkedSeq class, you should write a small test program that makes sure the method works correctly.

Turn in a zip file called CS275Hw3Surname.zip (where Surname is your last name) containing your version of IntLinkedSeq.java.

This assignment is due Tuesday, October 31.