Question: Need some help finishing this Array List public class MyStringArrayList { private String[] array; //container of this array list private static final int CAPACITY =

Need some help finishing this Array List public class MyStringArrayList { private String[] array; //container of this array list private static final int CAPACITY = 10; // initial capacity of the array private int size; // number of elements in the array /** * This default constructor sets the container capacity to be 10 and size to * 0, where container is empty. */ public MyStringArrayList() { array = new String[CAPACITY]; size = 0; } /** * requires: e != null * ensures : e added to the end of this array list. * Add a new element at the end of this list * @param e - element to be added */ public void addLast(String e) { if (isFull()) { // increase capacity if array is full String[] temparray = new String[array.length + CAPACITY]; for (int i = 0; i < array.length; i++) { temparray[i] = array[i]; } array = temparray; // make temparray the container } array[size] = e; //add element e to last empty location. size++; // increment the size of this array list } /* This method is only used by this class.
 * returns true if this array list is full, otherwise returns false. */ private boolean isFull() { return size == array.length; } /** * returns the current size (# of elements) of this list * requires: none * ensures: self.size == #self.size * @return current size of this array list */ public int getSize() { return size; } /** * Add a new element at the front of the array, shift elements over one index * @param s TODO write what this parameter corresponds to */ public void addFront(String s){ } /** * Return false if array list contains String s * @param s TODO write what this parameter corresponds to * @return TODO write what this return corresponds to */ public boolean contains(String s){return false; } /** * Check element in requested index * @param i TODO write what this parameter corresponds to * @return TODO write what this return corresponds to */ public String getElement(int i){ return array[i]; } /** * Remove an element from the leftmost index until to the desired element * @param i TODO write what this parameter corresponds to * @return TODO write what this return corresponds to */ public String removeElementAt(int i){ return ""; } /** * Return and display string * @return TODO write what this return corresponds to */ public String toString(){ return "<>"; } }

To complete this assignment you must do the following:

  • Create a minimum of four test cases for the getElement method.
  • Create a minimum of four test cases for the contains method.
  • Create a minimum of four test cases for the removeElementAt method.
  • Create a minimum of four test cases for the addFront method.
  • Create a minimum of four test cases for the toString method.
  • Have all tests pass.
  • Fill out the javadocs in /src/main/java/MyStringArrayList.java for all methods.

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!