CSC 210 Homework 2

Linked Lists Exercises

In this set of exercises, you will gain experience working with linked lists by implementing methods on a linked list class provided by the instructor. You can download the zipped up Netbeans project here. Unzip it into a local folder and run the code inside. You will see the interface shown in the following image.

The program implements a list of strings. At the top of the program's main window, you will see three lists of available commands. Here, index represents an integer index into the list, while string represents a string value. The complete list of available commands is shown below:

void add(String value)
void add(int index, String value)
void addList(String []values)   // Example: addList ann joe beth billy
boolean remove(String value)
void removeAll(String value)    // remove all occurrences of the string from the list
String remove(int index)
int size()
String get(int index)
String set(int index, String value)
int indexOf(String value)
boolean contains(String value)
int count(String value)
void upperCase(int index)
void lowerCase(int index)
void reverse()

Some of these methods, like the size() and add() have already been implemented. Methods not already implemented throw an UnsupportedOperationException. Remove the exception code and replace it with your own code.

To test a method, simply type the name of the method followed by the parameters. If there is more than one parameter, the parameters are separated by spaces. For example,

add one
indexOf mama
count mama
uppercase 2
reverse
size

Notice that you do not have to understand all of the code in the project shell to so the assignment. Begin by locating the class CSC210List in the code. You need to understand that this class uses a Node class and a reference first of type Node to implement a linked list. These implementation details should not be changed. Next, study the code for the add() and size() methods to make sure you understand the implementation. After this, all you need to do is to provide implementations of the rest of the methods in this class.

Despite the due date below, I expect you to understand linked list operations for the quiz, so it would be wise to complete this assignment by Wednesday.

Due Date: Saturday at the end of Week 3.