CSC241 Assignment 4


This assignment asks you to write the beginnings of a front-end for a usenet news newsreader. The high-level description of main functionality is:

The presentation details are up to you. The implementation restrictions are:


The newsgroup file

The file accessible at 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: 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.)

Finding and displaying prefixes

To find selections, you will need to do a partial traversal of the tree, placing all elements that 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.

Firing up the newsreader

Inside an Applet, you can fire up the netscape newsreader using code along the lines of:
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.

Doug Lea
Last modified: Fri Dec 6 11:34:05 EST