I need the specification and implementation of a new data type that holds terms extracted from document(s). Such a data type will not allow duplication of terms in each instance. A minimum of:

1 creator method,

3 mutator methods,

3 observer methods are required.

Also,a separate test program is to be implemented to read a text document (provided by a user) and extract each term contained in the document. Extracted terms from a single document will be stored in an instance of the newly created data type,

i.e. for each text document, there will be an instance of the newly created data to hold terms extracted from the document.

I have tried this this code but it didn't work, I am stucked:

import java.util.*;
import java.io.*;

public class TermExtractor;  {

  Scanner reader = new Scanner (new File ("terms.txt");

      public void readFileLine(Scanner reader) {
      Iterator<String> itr = reader.iterator();
      while (reader.itr = reader.iterator();
          String termLine = reader.nextLine();
          Scanner LineTermProcess = new Scanner (termLine);
          while (termLine.hasNext())  {
               String term = lineTermProcess.next();
               System.out.print(term);
          }
          System.out.println();
      }
}
pubic void termReadBefore(Scanner reader)  {
    iterator<String> itrt = reader.iterator();
    while (reader.hasNextLine())  {
         String termLineBefore = reader.nextLine();
         Scanner lineTermProcessBefore = new Scanner(termLineBefore);
         while (termLineBefore.hasNext())  {
              Do   {
                  String termBefore = lineTermProcessBefore.next();
                  System.out.print(termBefore);
              while (termBefore != lineTermProcessBefore()) 
              }
              System.out.println();

          } 
     }
}

You only need one Scanner. You don't need an Iterator to use a Scanner.

Before posting code here, compile it and deal with as many of the compiler errors as possible before asking for help.

You were asked to implement a new data type ("class" in Java), and you have been told some of the things your class should have. Define that class before trying to write a test program that uses it.

Nobody here knows your level of experience, so nobody knows what kind of "assistance" you need. If you cannot ask specific questions then all I can suggest is that you look at some of the tutorial resouces listed here.

This article has been dead for over six months. Start a new discussion instead.