Lab 5

Code for this lab

Same deal as the last lab, go ahead and pull the code and import it into eclipse

This lab has a few errors in it, just like the one before it, we will have to fix that!

We will only be editing the ManagedList.java for this lab

If you look at the ManagedList class you will see 3 empty methods, a constructor that we don't need to change, and a toString(). For this lab we will just be filling in the 3 methods that are empty.

The three methods are doTheWork, insertionSort, and pullLineForward

I will start by explaining what the lab is supposed to do. Inside the doTheWork method we are first going to populate the ArrayList with OneLines We will use the parameter inFile to access this data, you can look through the OneLine class to see what methods you should use for this. After the data is read in you will call the insertionSort method, and then print the the output file using outFile.printf and the toString method for this class.

The insertionSort method is really simple, the idea for it is to look at every element in the list, from element 1 (note not element 0) to the last element, and call the pullLineForward method on it.

The pullLineForward method is a bit more complicated. What you will do is the actual comparing for the insertion sort here. Going from the element index that is passed in to the method to 1 you will compare each element with the one before it (you can use compareTo for this) and if it is supposed to be in front of it you switch them.

That's all you need to get it running! I am going to get progressively more vague and being to give you less and less for each lab. Eventually we will get to a point where you create the whole class yourself, probably starting with the Lab test that is next week (July 1)

Zip up the folder and submit to dropbox!