Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objectives: Write an array-based ArrayList class that implements the UnorderedLi

ID: 650056 • Letter: O

Question

Objectives:

Write an array-based ArrayList class that implements the UnorderedListADT and IndexedListADT interfaces.

Write a test class called ListTester to test your ArrayList for UnorderedListADT and IndexedListADT functionality.

Implement ArrayList as an UnorderedListADT and IndexedListADT

Write class ArrayList to implement both UnorderedListADT and IndexedListADT with the list managed internally using an array.

You may use the following code as a starting point, if you wish:

AbstractArrayList.java - starting file containing code already provided by the book.

ArrayList.java - starting file containing code already provided by the book.

Testing

Test your ArrayList using a test class called ListTester that builds on the tests developed through List Test Part 1 and Part 2. (Many tests for UnorderedListADTmethods should already be written and can be copied over to the new test class without modification.)

For each scenario you tested for UnorderedListADT, you will need to add new tests for the methods in IndexedListADT.

The addition of IndexedListADT methods that modify the list (add(T element), add(int index, T element), remove(int index), and set(int index, T element)) also means there are new scenarios that should be tested, in addition to those from UnorderedListADT.

Explanation / Answer

Please provide complete details for the program where is ArrayList class or AbstarctArrayList class from the TextBook Please check .............. Reference: http://faculty.washington.edu/moishe/javademos/jss2/ArrayUnorderedList.java Reference: http://cs.boisestate.edu/~cs221/homeworks/DataStructures/DataStructures_files/OrderedArrayList.java public class ArrayUnorderedList extends ArrayList implements UnorderedListADT { //----------------------------------------------------------------- // Creates an empty list using the default capacity. //----------------------------------------------------------------- public ArrayUnorderedList() { super(); } //----------------------------------------------------------------- // Creates an empty list using the specified capacity. //----------------------------------------------------------------- public ArrayUnorderedList (int initialCapacity) { super(initialCapacity); } //----------------------------------------------------------------- // Adds the specified element to the front of the list. //----------------------------------------------------------------- public void addToFront (T element) { if (size() == list.length) expandCapacity(); // shift elements to make room for (int scan=rear; scan > 0; scan--) list[scan] = list[scan-1]; list[0] = element; rear++; } //----------------------------------------------------------------- // Adds the specified element to the rear of the list. //----------------------------------------------------------------- public void addToRear (T element) { if (size() == list.length) expandCapacity(); list[rear] = element; rear++; } //----------------------------------------------------------------- // Adds the specified element after the specified target element. // Throws a ElementNotFoundException if the target is not found. //----------------------------------------------------------------- public void addAfter (T element, T target) { if (size() == list.length) expandCapacity(); int scan = 0; while (scan scan; scan2--) list[scan2] = list[scan2-1]; list[scan] = element; rear++; } } public class OrderedArrayList extends AbstractArrayList implements OrderedListADT { /** * Creates an empty list using the default capacity. */ public OrderedArrayList() { super(); } /** * Creates an empty list using the specified capacity. * * @param initialCapacity the initial size of the list */ public OrderedArrayList(int initialCapacity) { super(initialCapacity); } /** * Adds the specified Comparable element to this list, keeping * the elements in sorted order. * * @param element the element to be added to the list */ public void add(T element) { if (!(element instanceof Comparable)) throw new NonComparableElementException("OrderedList"); Comparable comparableElement = (Comparable)element; if (size() == list.length) expandCapacity(); int scan = 0; // find the insertion location while (scan 0) scan++; // shift existing elements up one for (int shift=rear; shift > scan; shift--) list[shift] = list[shift-1]; // insert element list[scan] = element; rear++; modCount++; } }