The files you are going to need are
In the LwC_Utils class are six 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:
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, CAT, DOG, PIG, CAT, PIG, ELK, MOOSE, T-REX, ELK, ELK, COW, DOG, BEAR] After listifying, the list is PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR The length of the list is 15 ----------------------------------- The list is PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR Testing the findNext() method... Looking for PIG ... Found at front of list. Found at node with predecessor DOG Found at node with predecessor CAT Found 3 occurrences of PIG Looking for DOG ... Found at node with predecessor PIG Found at node with predecessor CAT Found at node with predecessor COW Found 3 occurrences of DOG Looking for CAT ... Found at node with predecessor DOG Found at node with predecessor PIG Found 2 occurrences of CAT Looking for COW ... Found at node with predecessor ELK Found 1 occurrences of COW Looking for ELK ... Found at node with predecessor PIG Found at node with predecessor T-REX Found at node with predecessor ELK Found 3 occurrences of ELK Looking for LION ... Found 0 occurrences of LION Looking for BEAR ... Found at node with predecessor DOG Found 1 occurrences of BEAR ----------------------------------- The list is PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR Testing the findFirst() method... Looking for first occurrence of PIG ... Found at front of list. Looking for first occurrence of ELK ... Found at node whose predecessor contains PIG Looking for first occurrence of DOG ... Found at node whose predecessor contains PIG Looking for first occurrence of LION ... Not found. ----------------------------------- The list is PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR Testing the insertNonDuplicate() method... Inserting (if not a duplicate) GORN ... Afterwards, the list contains PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR GORN Inserting (if not a duplicate) CAT ... Afterwards, the list contains PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR GORN ----------------------------------- The list is PIG DOG CAT DOG PIG CAT PIG ELK MOOSE T-REX ELK ELK COW DOG BEAR GORN Testing the removeDuplicates() method... Removing all duplicates ... Afterwards, the list contains PIG DOG CAT ELK MOOSE T-REX COW BEAR GORN ----------------------------------- The list is PIG DOG CAT ELK MOOSE T-REX COW BEAR GORN Testing the reverse() method... Reversing the list ... Afterwards, the list contains GORN BEAR COW T-REX MOOSE ELK CAT DOG PIG Goodbye from LwC_UtilsTester |