Lab - Using Position's and List's

Overview

This lab is to introduce you to working with the Position ADT and the List ADT. Your goals are to write the following two routines:

Do not even attempt the second method unless you have successfully written and tested the first method.

GroupDriver

The driver for this lab (GroupDriver) is nothing fancy, but it will do the job. As a user, you are to enter numbers between 0 and 999, one at a time. Every time you enter a valid number, that number will be added to the current List, and your Print routine will be called by the driver to display the updated List. The value ``1000'' is used to restart with an empty list and the value ``-1'' exits the driver.

By default, the new number is added at the end of the current list. However, if you have (correctly) implemented the Find method, the driver will first call your method to search the existing List, looking for a number which is equivalent to the new number. If such a number is found, the new number will be placed in the List next to the previously exising copy. In this way, multiple copies of the same number will be grouped together.

Summary of Position and List ADTs

You may use the Position and List interfaces, as described in Chapter 5.2.2 and 5.2.3 of the text.

In particular, the Position data type supports the methods:
public Object element()

The List interface supports the following inquiry methods:
public int size()
public boolean isEmpty()
public Position first()
public Position last()
public boolean isFirst(Position p)
public boolean isLast(Position p)
public Position before(Position p)
public Position after(Position p)

There are other methods in the List interface which allow you to modify or update the list. The full ADT is given in chapter 5.2 of the text, however in this particular lab you will never need to modify the list.

Files you will need

Although you will only need to modify one file (Student.java), you will need to download several files we provide.

Handing in your completed lab

You do not have to submit any files electronically. You should instead make a printout of the modified file Student.java and make sure your name is written clearly at the top of the file.


Last modified: Tue Sep 24 08:38:48 CDT 2002