Question: 1 Introduction A sequence is an ordered list of elements that grows as necessary to hold everything you try to put in it. For this

1 Introduction

A sequence is an ordered list of elements that grows as necessary to hold everything you try to put in it. For this assignment you will develop a sequence abstract data type (ADT) using linked lists. Recall that an ADT defines a type and a set of operations on that type. It is abstract in the sense that users of the type dont need to know about the details of how the data is stored or how the operations work they just work.

A sequence has a notion of a current element." Several of the operations on a sequence are in terms of the current element.

2 Details

For this assignment, you will implement the DoubleLinkedSeq class described in Section 4.5 of your textbook (pages 235-238). See the API documentation in the text for a description of the class and the methods that it must provide. Additionally, you must provide (1) a toString() method that returns a String representation of the DoubleLinkedSeq and (2) an equals() method that determines if two DoubleLinkedSeq are equal.

  1. The toString() method must return a string in the following form. If the sequence is empty, the method should return <>. If the sequence has one item, say 1.1, and that item is not the current item, the method should return <1.1>. If the sequence has more than one item, they should be separated by commas and a space, for example: <1.1, 2.2, 3.3>. If there exists a current item, that item should be surrounded by square braces. For example, if the second item is the current item, the method should return: <1.1, [2.2], 3.3>.
  2. the equals() method should return true if the two sequences contain the same number of elements, if the corresponding entries in the sequence are the same, and if they have the same current element.

package skeleton; /** * A DoubleLinkedSeq is a sequence of double numbers. The sequence can have a * special "current element", which is specified and accessed through * four methods that are not available in the IntArrayBag class (start, * getCurrent, advance, and isCurrent). * * Limitations: * * Beyond Integer.MAX_VALUE element, the size method does not work. * * @author ??? * @version ??? */ public class DoubleLinkedSeq implements Cloneable {

// your non-static fields go here.

public DoubleLinkedSeq() { // code for constructor }

public void addBefore(double element) { // code for addBefore }

public void addAfter(double element) {

// your code here }

public void addAll(DoubleLinkedSeq other) throws NullPointerException { // your code here }

public void advance() throws IllegalStateException { // your code here }

public DoubleLinkedSeq clone() throws RuntimeException { // your code here. see textbook for hints // change this return! return null; }

public static DoubleLinkedSeq concatenation(DoubleLinkedSeq s1, DoubleLinkedSeq s2) throws NullPointerException { // your code here. // change this return! return null; }

public double getCurrent() throws IllegalStateException { // your code goes here // change this return! return -Double.NEGATIVE_INFINITY; }

public boolean isCurrent() { // your code return false; }

public void removeCurrent() throws IllegalStateException { // your code goes here }

public int size() { // your code goes here return Integer.MIN_VALUE; }

public void start() { // your code goes here. }

@Override public String toString() { // your code here. // change this return! return null; }

public boolean equals(Object other) { // your code goes here // change this return! return false; } }

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!