Bill Teter
Office:          149 Redcay
Telephone:    2782
Office Hours:  Tuesday, Thursday 9:00-12:00

email:  william.teter@plattsburgh.edu

       

 

Lab 4 -- Strings and ArrayLists

A concordance stores data about words that occur in text.  Typically what is stored is the name of the book (or file) in which the word occurs and the page (or line) number of the occurrence.  In this lab you will build a simple concordance system that will process any number of text files.  You can run my version of this program if you copy the Test.class file into you account:
    /home/teterwa/public/csc223/lab4Solution/Test.class 

The project will involve 3 classes:

Test -- creates the concordance from a command line argument that contains any number of filenames of text files, prints the filenames and then responds to queries from user about location of words in the files.

WordData -- A class that contains three (private) fields:
        the word
        the line number on which it occurred
        the name of the text in which the word occurs
The methods in this class are:
        a constructor that includes values for each field
        an accessor for each field
        a toString() method

Concordance-- A class that holds  an ArrayList that contains all the WordData objects found in the texts processed in the concordance.  Also, the concordance holds an ArrayList of the names of the textfiles.
The methods of the class are:

public void processFile(String fn)
// given the name of a text file, all the words in the text file are added to the concordance.

public ArrayList<Strings> getTexts()
// returns the arrayList of filenames.

public ArrayList<WordData> getReferences(String wd)
// returns the array list of all word Data objects for the word wd.
  

Step 1.
    Create a directory called lab4.  Copy into it all the files in
/home/teterwa/csc223/lab4/

Step 2. 
    The Test program is complete and should need no changes.  Fill in the code for all the missing methods and do any necessary "news" for fields in the classes.