Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If you can do this in java. Thanks lab5(chap4b).csc103.docx - Word Review View Tell me what you want to do... E7 3 2 33 E-

If you can do this in java. Thanks image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
lab5(chap4b).csc103.docx - Word Review View Tell me what you want to do... E7 3 2 33 E- AaBbCcDc AaBbCcDc AaBb C AaBb 1 Normal 1 No Spac... Heading 1 Headin Paragraph 2 write the removeCurrent method for the Double LinkedSeg class override the equals method for the Double LinkedSeq class Up 10 bond Version of the DoublelinkedSeg Class * DoublelinkedSeq public class Double LinkedSeq from the package edu.colorado.collections in the bag class (start, getCurrent, advance, and isCurrent). "current element, which is specified and accessed through four methods that are Beyond Int.MAX_VALUE elements, the size method does not work. Constructor for the Double LinkedSeq public DoublelinkedSeg() Initialize an empty sequence. Postcondition: This sequence is empty. 236 Chapter LinkedIn (FIGURE 4.18 continued addAfter and add Before public void addAfter (double element) Adds a new element to this sequence either before or after the current element. public void addBefore(double element) Parameter: element - the new element that is being added Postcondition: addAfter places the new element after the current element, and addBefore places the new clement before the current element. If there was no current element, addAfter places the new element at the end of the sequence, and addBefore places the new element at the front of the sequence. The new clement always becomes the new current element of the sequence, Throws: OutOfMemoryError Indicates insufficient memory for a new node. . addAll public void addA11 (DoublelinkedSeq addend) Place the contents of another sequence at the end of this sequence. Parameter: addend - a sequence whose contents will be placed at the end of this sequence Precondition: The parameter, addend, is not null. Postcondition: The elements from addend have been placed at the end of this sequence. The current element of this sequence remains where it was, and the addend is also unchanged. Throws: NullPointerException Indicates that addend is null Throws: OutOfMemoryError Indicates insufficient memory to increase the size of the sequence. advance public void advance) Move forward so that the current element is now the next element in the sequence. Precondition: isCurrent() returns true. Postcondition: If the current clement was already the end element of the sequence (with nothing after it), then there is no longer any current element. Otherwise, the new element is the element immediately after the original current element. Throws: IllegalStateException Indicates that there is no current element, so advance may not be called. (continued Programming Project: The Sequence ADT with a Linked List 237 18.com ulic Object clone) le a copy of this sequence. it is used Throws: OutOfMemoryError the original, nor vice versa. The return value must be typecast to a DoublelinkedSeq before The return value is a copy of this sequence. Subsequent changes to the copy will not affect Indicates insufficient memory for creating the clone. Ulic static DoublelinkedSeq concatenation Create a new sequence that contains all the elements from one sequence followed by another. si - the first of two sequences $2-the second of two sequences catenation Parameters: Precondition: Neither si nor s2 is null. Returns: a new sequence that has the elements of si followed by s2 (with no current element) Throws: IllegalArgumentException Indicates that one of the arguments is null. Throws: OutOfMemoryError Indicates insufficient memory for the new sequence. Current public double getCurrent Accessor method to determine the current element of the sequence. Precondition: isCurrent() returns true. Returns: the current element of the sequence Throws: IllegalStateException Indicates that there is no current element. Current public boolean isCurrent() Acessor method to determine whether this sequence has a specified current element that ca be retrieved with the getCurrent method. true (there is a current element) or false (there is no current element at the moment) (conti Returns: Pol 38 Chapter 4 / Linked Lists FIGURE 4.18 continued) removeCurrent public void removeCurrent Remove the current element from this sequence. Precondition: isCurrent returns true. Postcondition: The current element has been removed from the sequence, and the following elemen there is one) is now the new current element. If there was no following element, there is now no current element. Throws: IllegalStateException Indicates that there is no current element, so removeCurrent may not be called, size public int size() Accessor method to determine the number of elements in this sequence. Returns: the number of elements in this sequence start public void start Set the current element at the front of the sequence. Postcondition: The front element of this sequence is now the current element (but if the seque elements at all, then there is no current element)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

What will be the role of the consultants in this process?

Answered: 1 week ago