import java.util.ArrayList;

public class WordList
{
  private ArrayList myList;  // acontains Strings made up of letters

  public WordList(ArrayList words)
  {
    myList = words;
  }

  // postcondition: Returns the number of words in this WordList that
  //                are exactly len letters long
  public int numWordsOfLength(int len)
  { int count = 0;

    for(int k = 0; k < myList.size(); k++)
    { String word = (String)myList.get(k);
      if(word.length() == len)
        count++;
    }
    return count;
  }

  // postcondition: All words that are exactly len letters long
  //                have been removed from this WordList, with the order of
  //                the remaining words unchanged
  public void removeWordsOfLength(int len)
  { int k = 0;

    while(k < myList.size())
    { String word = (String)myList.get(k);

      if(word.length() == len)
        myList.remove(k);
      else
        k++;
    }
  }

// alternate solution
/*
  { for(int k = 0; k < myList.size(); k++)
    { String word = (String)myList.get(k);

      if(word.length() == len)
      { myList.remove(k);
        k--;
      }

    }
  }
*/

  public void printWordList()
  { System.out.println(myList);
  }
}
