back to labs page

Lab 5

ListArray

Concepts Covered: Building a list data structure using an array

Due: Preferably at the end of the day on Wednesday

Files you need: List.java, ListArray.java

Turn in: ListArray.java, ListArrayTester.java

Requirements: You are given the List interface. Your job is to implement the List interface via a class that uses an array. You are also required to write a program that tests your ListArray class to make sure it is working properly. You should write the code for these two programs simultaneously (i.e. write a method in the ListArray class, and then write code that tests that it is working properly in the ListArrayTester program).

Please note that there are slight differences in the code that is included here and the code that is in your lab manual. Implement the methods as they are described here!

Do the following in order:

  1. Read the Prelab Exercise Introduction on page 85-86 of your lab manual.
  2. Download the necessary files.
  3. Write the method headers (along with empty bodies) for all of the necessary methods in the List.java file. Compile it to make sure that it compiles properly.
  4. Fill in the variable declarations and constructors for the List.java class, and create a List object in the ListArrayTester program. Compile it and make sure it works.
  5. Begin working on the methods, one at a time. For each method, make sure you add a few lines in your ListArrayTester program that verifies that the method is working properly. Note that it may be helpful to implement the showStructure() method early, so that you can see the contents of your ListArray after you call each of the methods. Also note that you can insert primitive types (like ints) into your list using the associated wrapper class (for example, Integer). This will be the easiest way to test your list.
  6. When you are finished, submit your code to the dropbox.