CMPS 144L
Activity: Developing Utility Methods for Lists with Cursors

The files you are going to need are

In the LwC_Utils class are five stubbed methods that you are to attempt to complete. They are clearly marked by STUB! and their comments should suffice to explain their intended behavior. Several other (complete) methods are present, in part to give you examples that you can use as models. When you are finished, you should submit the source code file of this class to the appropriate dropbox. (Again: Submit the .java file, not the .class file!)

LwC_UtilsTester is a Java application that you can use to test your work. You are free to modify it to suit your testing needs. The section below says more about this application.

The remaining Java classes implement the "List with Cursors" abstraction and are not to be modified. To view the full array of methods available to list and cursor objects, see the ListWithCursors and ListCursor interfaces. (Unless you are interested in the gory details of implementation, don't view the contents of LwC_ViaArray.)

Note:


LwC_UtilsTester

The LwC_UtilsTester program is rather primitive, in that there is no interaction between it and a user. Rather, the program simply creates a "hard-coded" list of animals —well, really a list of elements of type String that are names of animal species— and then invokes some of the methods in LwC_Utils, including those that were orginally stubbed. After each method call, a message is printed that should provide some evidence of whether or not the method worked as intended.

You are encouraged to modify the program to suit your own testing needs.

If everything works as intended, the output produced by the program (as given) will be as follows:

LwC_UtilsTester Program starting execution...

The array to be listified:
  [PIG, DOG, DOG, DOG, CAT, PIG, ELK, MOOSE, T-REX, ELK, ELK, COW, DOG, BEAR]

After listifying, the list is
  PIG DOG DOG DOG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR

The length of the list is 14

Trying to find PIG ...
Found at front of list.

Trying to find CAT ...
Found at node whose predecessor contains DOG

Trying to find COW ...
Found at node whose predecessor contains ELK

Trying to find LION ...
Not found.

Trying to find BEAR ...
Found at node whose predecessor contains DOG

Inserting (if not a duplicate) GORN ...
Afterwards, the list contains
  PIG DOG DOG DOG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR GORN

Inserting (if not a duplicate) CAT ...
Afterwards, the list contains
  PIG DOG DOG DOG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR GORN

Removing all duplicates ...
Afterwards, the list contains
  PIG DOG CAT ELK MOOSE T-REX COW BEAR GORN

Reversing the list ...
Afterwards, the list contains
  GORN BEAR COW T-REX MOOSE ELK CAT DOG PIG

Goodbye from PLC_Utils_Tester