lab3tester.jpg
Attachment 587
As showed above, Default constructor and default constructor with given size gives OK. But when I run the iterator, nothing is shown for the output.
Printable View
lab3tester.jpg
Attachment 587
As showed above, Default constructor and default constructor with given size gives OK. But when I run the iterator, nothing is shown for the output.
You need to add some println debugging code to see where the execution flow goes and what the values of the variables are as they are used and change. From your desk checking with paper and pencil you should know what the variables' values should be at each step so you can compare the printed output with what you expect the values to be and determine what is wrong with the code.Quote:
nothing is shown for the output.
When I run your iterator, it works OK - although because the list acts more like a stack if you use insertItem, so the items I inserted came out of the iterator in reverse order of insertion.
I have to say that this 'SimpleComparableList' doesn't seem all that simple to me - the insertItem method seems counter-intuitive, and the currentPosition idea is a confusing complication - next() and prev() don't return the next and prev items, although the iterator next() does return the next item... YMMV.