import java.util.List; import java.util.ArrayList; /** * Class to do work on a list of strings */ public class StringListWorker2 { /** holds a list of strings */ private List stringList = null; /** Constructor that takes a list of strings * @param theList the list to use */ public StringListWorker2(List theList) { this.stringList = theList; } /** * Method to return a new list that has every other * string in it from the original list of strings in stringList * @return an ArrayList with every other item in it from the * original list of strings */ public List getEveryOther() { } /** * Method to return the number of strings that contain the * passed substring * @param sub the substring to look for * @return the count of the number of strings in the list that * contain the passed substring or 0 if none. */ public int getCount(String sub) { } /** * Method to return a new list of strings that contains the * same strings as in the original but in reverse order * @return a new list of strings in reverse order */ public List reverse() { } public static void main(String[] args) { List theList = new ArrayList(); theList.add("bug"); theList.add("bear"); theList.add("bat"); theList.add("lake"); theList.add("pool"); theList.add("bake"); theList.add("horse"); StringListWorker2 worker = new StringListWorker2(theList); List everyOtherList = worker.getEveryOther(); if (everyOtherList.size() != 4) System.out.println("error in every other list"); System.out.println("after every other"); for (String currString : everyOtherList) System.out.println(currString); int count = worker.getCount("ak"); System.out.println("count of ak is " + count); if (count != 2) System.out.println("error in getCount for ak"); count = worker.getCount("zeb"); System.out.println("count of zeb is " + count); if (count != 0) System.out.println("Error in getCount for zeb"); List revList = worker.reverse(); System.out.println("after reverse"); for (String currString : revList) System.out.println(currString); } }