In the add method of the OrderedLinkedList class I am trying to place nodes with the same data items consecutively. As I have it now, the nodes are added in the order they are listed in the Test Harness.
Here is the output:
Sue, Bill, Michael, Someguy, Michael, Carl, Steve, Carl, Sue
Sue, Bill, Someguy, Michael, Steve, Carl, Sue
Sue, Bill, Someguy, Michael, Steve, Carl, Sue, Sue, Bill
Ian Mcloud wrote:
I know I need to compare the previous node with the newNode,
Which previous node? Previous to what? It sounds like you're saying you'll make exactly one comparison, which in turn suggests you haven't thought through the "by hand" approach as thoroughly as you ought. You need to be able to describe your steps precisely before you jump into writing Java code.
Also, though it's not a big deal, is there any particular reason you're using Comparable here, instead of just using the equals() method? (There is actually a reason you might use it which could improve performance, but I want to know why you chose it.)
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop