Traversing The List

The goal for this exercise is to add a Print method to your simple Linked List class, in order to gain experience with algorithms that traverse a linked list.

For this exercise, you need to implement the PrintAll method in the provided MyIntList class, as well as any other methods that you need to implement in order to accomplish the goal of implementing this method.  This class should be found in the Student_Answers.cs file.

            The ‘PrintAll’ method should iterate through all the nodes, one at a time, and call the Print method on each one.  (Obviously, if your LinkedListNode class doesn't yet have a Print method, you'll have to add one).   The print method for each node should print out a single line, that contains only the number (the Data) that the node is storing.  Because PrintAll should call this method on each object in sequence, the correct output calling PrintAll on a list that contains {1, 2, 3} should be:

1
2
3

Hint: Start at one end of the list, and continue to loop while your reference isn't null, printing as you go.

What you need to do for this exercise

  1.  Implement PrintAll, as described above

    1. Implement anything required by PrintAll

  2. Once you’ve completed the above task, you should run the tests in the NUnit_Tests_LL_PrintAll  class.  They should all pass at this point, and if not, then you should fix your program so that those tests do pass.  You can run the tests using the NUnit support in the provided starter project.  You should feel free to supplement that code with your own test cases if you wish, but you are neither required nor expected to.