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

public class StringBag { // the array to hold the data private String [] bag; //

ID: 3914239 • Letter: P

Question

public class StringBag {

   // the array to hold the data

   private String [] bag;

  

   // the number of elements being held (also the next index where a new

   // String can be put).

   private int count;

  

   public StringBag(int length) {

      bag = new String[length];

      count = 0;

   }

}

c. [2 points] Write a function that determines the index of a String in the StringBag. It should return the index if found, or -1 if it is not found. i. Write your test case for this method. @Test public void testIndexOf() { // Replace this test with your code } ii. Write your method. public int indexOf(String item) { // Replace this test with your code }

Explanation / Answer

========================================================