2014-03-19 Lab

posted Mar 19, 2014, 8:44 AM by Samuel Konstantinovich   [ updated Mar 19, 2014, 9:58 AM ]
You are writing two classes, and a driver to test them. Test each method as you write them.

1. Node
-Node(String data
-Node getNext()
-String getData()
-void setData(String data)
-void setNext(Node next)
-String toString()   //Just return the data

All list like objects we make are indexed from 0. The 1st location is index 0.
2. MyLinkedList  //does not handle circular lists
-void add(String s, int position) //create a node containing s and add it to the position location. Throw an exception if position>=length of the list.
-String get(int position) // return the string found at the indicated position
-void set(int position,String newString) // change the value of the string found at the indicated position to newString
-void remove(int position)//remove the Node from that location.
-int find(String s)//return the location of the 1st occurance of s in the list, -1 if the string isn't found.
-int length() //return the number of elements stored in the linked list. 
-String toString() //convert the list to a string in the format "[ word1 , word2 , word3]"
Comments