Question: Your task is to create a public, concrete class named MyDoublyLinkedList that extends MyAbstractSequentialList and implements Cloneable: public class MyDoublyLinkedListBased on Exercise 2 4 .

Your task is to create a public, concrete class named MyDoublyLinkedList that extends MyAbstractSequentialList
and implements Cloneable:
public class MyDoublyLinkedListBased on Exercise 24.3(Implement a doubly-linked list):
Download the following files from the assignment page on Canvas -
MyDoublyLinkedList.java (this is the file that you will modify to include the additional methods)
MyList.java
MyAbstractList.java
MyAbstractSequentialList.java
TestMyDoublyLinkedList.java
Your task is to create a public, concrete class named MyDoublyLinkedList that extends MyAbstractSequentialList
and implements Cloneable:
public class MyDoublyLinkedList extends MyAbstractSequentialList
implements Cloneable {
The class must override the clone and equals methods that are inherited from the Object class. All supported methods
should work just like those in java.util.LinkedList.
Tip1: It is not necessary to override the equals method in MyDoublyLinkedList in order to write the contains, indexOf,
and lastIndexOf methods. The equals method that you will call in those methods is the one provided by the elements
of the list, not the equals method provided by the list class.
Tip 2: You need to make sure that you understand how the ListIterator is expected to work for implementing
MyAbstractSequentialList. The following is description of ListIterator from the Java Docs. Specifically, you have
to note how the remove() and set() methods work. Therefore,
If you have invoked next(), and then call the remove(), it will delete the node that is the previous of current.
If you have invoked previous(), and then call remove(), it will delete the node that is current.
If you have invoked next(), and then call set(), it will set the node that is the previous of current.
If you have invoked previous(), and then call set(), it will set the node that is the is current.
By default, you cannot call remove() or set() before invoking next() or previous().
After you have called add() or remove() once, you cannot call remove() or set() before invoking next() or
previous() again.
Tip 3: In the iterator's remove() method you will probably switch based on the value of iterState., which indicates if a
node can be deleted, cannot be deleted, and if the previous node can be deleted or not.
If the value of iterState is CAN_REMOVE_PREV, consider whether you need to update indexOfNext. (Hint:
The index of the next element will be changed by the deletion.)
If the value of iterState is CAN_REMOVE_CURRENT, consider whether you need to update current. (Hint:
You don't want current to point to a node that is no longer in the list.)
 Your task is to create a public, concrete class named MyDoublyLinkedList

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!