comp.lang
''). The program
then buids a menu list of all groups with that prefix, sorted by
number of articles.
The presentation details are up to you. The implementation restrictions are:
The file accessible at
http://www.oswego.edu/dl/newsgroups
is a
``.newsrc'' file containing a listing of all (about 4000) usenet
newsgroups received at oswego, along with the article numbers of
the first and last articles received (as of the date this file was
generated).
Each line has the following format:
the.news.group: firstNumber-lastNumber
For example
comp.publish.electronic.developer: 1-1055
You might represent this as simple data-record class such as:
class Newsgroup { String name; int first; int last; }
Some sample code for reading in newsgroup files is available HERE. (For illustration, this only reads into an array, you will instead want to insert each node into a tree.)
startsWith(prefix)
(see the Java
Package Documentation for class String
) into an
array-based class.
The version of quicksort from the class handout is available
HERE.
You can use this as a basis for a class named, for example
Selections
.
Note that you will need a special Comparator
that
helps order by number, not name.
To implement the prefix-select, consider defining a method in your
tree class: void insertAllWithPrefix(String prefix,
Selections sel)
that invokes sel.addElement
for each element it finds with the given prefix.
Check out the AWT documentation for MenuItem
and Menu
to find ways of making menus to display
selectable lists.
void showGroup(String name) { String addr = "news:" + name; URL url = new URL(addr); getAppletContext().showDocument(url); // displays in netscape news window }
However, this will not work in appletviewer
. You might
replace this code with just: System.out.println("Displaying " + addr)
until it is far enough along to test using netscape.
Test your program thoroughly before submitting.