Question: package ds.students; import ds.interfaces.List; /** * @author simont* */ public class DSList implements List { public Node head; private int size; public DSList() { head

package ds.students; import ds.interfaces.List; /** * @author simont* */ public class DSListimplements List { public Node head; private int size; public DSList() {head = null; } public DSList(Node head_) { head = new Node(head_.next,package ds.students; import ds.interfaces.List;

/** * @author simont* */ public class DSList implements List { public Node head; private int size;

public DSList() { head = null; }

public DSList(Node head_) { head = new Node(head_.next, head_.prev, head_.getToken()); }

public DSList(DSList other) { // Copy constructor. //NEED SOLUTION

}

public Token remove(int index) //NEED SOLUTION { return null; }

public int indexOf(Token obj) { //NEED SOLUTION return -1; } public Token get(int index) { //NEED SOLUTION return null;

}

public boolean isEmpty() { return head == null; } public int size() { //NEED SOLUTION

return 0; }

@Override public String toString() { //NEED SOLUTION return ""; }

public boolean add(Token obj) { //NEED SOLUTION

return false;

}

public boolean add(int index, Token obj) { /eed solution return true;

}

public boolean contains(Token obj) { //NEED SOLUTION return false;

}

public boolean remove(Token obj) { //NEED SOLUTION return true; }

@Override public int hashCode() { return this.hashCode(); }

@Override public boolean equals(Object other) { return true; }

}

I have attached the List class that the DSList class extends, I have commented on all the methods that require solutions. Please reply with completed methods as per the List interface above the start of the DSList class.

package ds.interfaces; import ds.students. Token; /** * @author simont * */ public interface List { ** * /* * Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). * @param index Index at which to add * @param obj The object to add @return True if insertion was successful * * @throws NullPointerException if the given object is null * @throws IndexOutOfBounds Exception if the index is out of range */ public boolean add(int index, Token obj); /** * Returns true if the given object is contained in the list. * @param obj The object whose presence is to be tested * @return True if the list contains the given object * @throws NullPointerException if the specified element is null */ public boolean contains (Token obj); /** * * Remove the first instance of the given object from the list, if it exists @param obj The object to remove @return True if the object was removed * * @throws NullPointerException if the specified object is null public boolean remove(Token obj); ** * Remove the object at the specified index from the list, if it exists. * @param index The index to remove @return The object previously at the specified index 36 * * @throws IndexOutOfBounds Exception if the specified index is out of range */ public Token remove(int index); /** 36 * Get the object at the specified index, if it exists. @param index The index to retrieve @return The object at the specified index, if it exists. * * * @throws IndexOutOfBounds Exception if the specified index is out of bounds */ public Token get(int index); /** * * Returns the first index of the specified object, or -1 if the object does not exist * in the list. @param token @return the index of the specified token, or -1 if it is not contained in the list. */ public int indexOf(Token token); * ** * Appends the specified element to the end of this list. * @param obj The object to add. * @return True if the object has been added to the list. * * @throws NullPointerException if the specified object is null */ public boolean add(Token obj); /** * Returns true if this list contains no elements. * @return True if the list is empty. public boolean isEmpty(); ** * Returns the number of elements in this list. * @return The number of elements in this list. */ public int size(); /** * Returns a string containing the toString() for each object in this list. * @return The concatenated toString() for each element in this list */ @Override public String toString(); /** * Compares this list with the specified object for equality. * The equality comparison must be value-based rather than the default (reference based). * @param obj The object to compare against. * @return True if the specified object is value-comparatively equal to this list */ @Override public boolean equals(object obj); /** * * Returns the hashCode for this list. * (This method must satisfy the constraint that if List 11.equals(List 12), then 11. hashCode () == 12. hashCode () must also be true. @return the hashCode of this list. */ @Override public int hashCode(); package ds.interfaces; import ds.students. Token; /** * @author simont * */ public interface List { ** * /* * Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). * @param index Index at which to add * @param obj The object to add @return True if insertion was successful * * @throws NullPointerException if the given object is null * @throws IndexOutOfBounds Exception if the index is out of range */ public boolean add(int index, Token obj); /** * Returns true if the given object is contained in the list. * @param obj The object whose presence is to be tested * @return True if the list contains the given object * @throws NullPointerException if the specified element is null */ public boolean contains (Token obj); /** * * Remove the first instance of the given object from the list, if it exists @param obj The object to remove @return True if the object was removed * * @throws NullPointerException if the specified object is null public boolean remove(Token obj); ** * Remove the object at the specified index from the list, if it exists. * @param index The index to remove @return The object previously at the specified index 36 * * @throws IndexOutOfBounds Exception if the specified index is out of range */ public Token remove(int index); /** 36 * Get the object at the specified index, if it exists. @param index The index to retrieve @return The object at the specified index, if it exists. * * * @throws IndexOutOfBounds Exception if the specified index is out of bounds */ public Token get(int index); /** * * Returns the first index of the specified object, or -1 if the object does not exist * in the list. @param token @return the index of the specified token, or -1 if it is not contained in the list. */ public int indexOf(Token token); * ** * Appends the specified element to the end of this list. * @param obj The object to add. * @return True if the object has been added to the list. * * @throws NullPointerException if the specified object is null */ public boolean add(Token obj); /** * Returns true if this list contains no elements. * @return True if the list is empty. public boolean isEmpty(); ** * Returns the number of elements in this list. * @return The number of elements in this list. */ public int size(); /** * Returns a string containing the toString() for each object in this list. * @return The concatenated toString() for each element in this list */ @Override public String toString(); /** * Compares this list with the specified object for equality. * The equality comparison must be value-based rather than the default (reference based). * @param obj The object to compare against. * @return True if the specified object is value-comparatively equal to this list */ @Override public boolean equals(object obj); /** * * Returns the hashCode for this list. * (This method must satisfy the constraint that if List 11.equals(List 12), then 11. hashCode () == 12. hashCode () must also be true. @return the hashCode of this list. */ @Override public int hashCode()

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!