CMPS 144 Spring 2024
Prog. Assg. #4: Index Entry
Due: 11:59pm, Sunday, April 7

Background

An index is a list of index entries, each of which identifies a keyword and an associated list of references. Each reference identifies a "place" where the keyword appears. In the index of a textbook, a reference typically indicates a page number. A text file could have an index in which each reference identifies the line number of an occurrence of a keyword. In an index maintained by a search engine such as Google, a reference might identify a particular web page and thus might take the form of a URL rather than an integer.

For the purposes of this assignment, we will keep things simple, so references are integers!


Student's Task

Provided are the following Java compilation units (interfaces and classes). The reader will notice that the names of the list-related entities are different from those that have been used in class and on web pages, as the word "Positional" has been omitted. The concepts are the same, however.


Sample Interaction with IndexEntryTester

Notice that commands can be entered using either upper or lower case letters.

Welcome to the IndexEntryTester program.

Enter a keyword: glorp

> h
Q : to quit
H : to print this stuff
P : to display/print the index entry
I 35 : to add 35 into reference list
R 27 : to remove 27 from reference list

> P
keyword: "glorp"; references: ()

> i 25
keyword: "glorp"; references: (25)

> i 37
keyword: "glorp"; references: (25, 37)

> i 11
keyword: "glorp"; references: (11, 25, 37)

> I 20
keyword: "glorp"; references: (11, 20, 25, 37)
> R 20
keyword: "glorp"; references: (11, 25, 37)

> r 11
keyword: "glorp"; references: (25, 37)

> r 37
keyword: "glorp"; references: (25)

> r 25
keyword: "glorp"; references: ()

> i 15
keyword: "glorp"; references: (15)

> i 24
keyword: "glorp"; references: (15, 24)

> i 15
keyword: "glorp"; references: (15, 24)

> q
Goodbye.


Program Submission

Submit your completed IndexEntry Java source code (the .java file, not the corresponding .class file) to the appropriate Brightspace dropbox.

Make sure to complete the "header comments" by inserting your name where it belongs, by listing the names of any persons with whom you collaborated in developing your solution, and by describing any flaws/defects in your work of which you are aware.