Question: Implement the Sequence class from Section 4.5. Outline of Java code for this class is available in DoubleLinkedSeq.java. Your sequence class must have five private

Implement the Sequence class from Section 4.5. Outline of Java code for this class is available in DoubleLinkedSeq.java. Your sequence class must have five private instance variables as described in Section 4.5. You need to use DoubleNode.java for your node class. Follow instructions from Section 4.5, except that you do not need to put your class in a package. You need to write the invariant for your sequence ADT (invariant is explained on p.126). You need to add implementations instead of blank implementations for the following: constructor DoubleLinkedSeq( ) addAfter addBefore addAll advance clone concatenation getCurrent isCurrent removeCurrent size start In addition to that you need to implement the following methods: addAtFront - a method to add a new element at the front of the sequence removeAtFront - a method to remove the element at the front of the sequence toIth - a method that makes the ith element become the current element (assume that the front element is the 1st) toString - a method that represents the sequence as a string (in any reasonable format which shows the order of elements) reverse a method that returns a new sequence that contains the same elements as the original sequence but in reverse order. The original sequence should remain unchanged. For instance, if original sequence contains elements 1.2 - 3.5 - 4.3 - 6.44 in this order, then the new sequence should contain elements 6.44 - 4.3 - 3.5 - 1.2. The header of the method should be the following: public DoubleLinkedSeq reverse( ) everyOther a method that returns a new sequence that contains every other element of the original sequence. The original sequence should remain unchanged. For instance, if original sequence contains elements 1.2 - 3.5 - 4.3 - 6.44, then the new sequence should contain elements 1.2 - 4.3. If the original sequence contains elements 3.2 - 2.5 - 1.0 - 7.1 - 9.5, then the method should return sequence 3.2 - 1.0 - 9.5. The header of the method should be the following: public DoubleLinkedSeq everyOther( ) removeSmaller a method that removes from the sequence all elements that are less than a given value which is passed as a parameter. For instance, if original sequence contains elements 5.2 - 3.5 - 4.3 - 6.44 2.5 and the value is 5.0, then the sequence should become 5.2 - 6.44. If all elements in the sequence are less than the value, then the sequence should become empty. The header of the method should be the following: public void removeSmaller(double value) 2: Write a test program to test your code. Name your test program TestSequence. Your test program should test all the methods in your DoubleLinkedSeq class.

I need help with the method/testing of reverse, everyOther, concatenation, removeSmaller, advance, and toIth.

Thanks!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!