posted 18 years ago
You poor fellow -- you seem to have been wrestling with this for days.
You have an ArrayList which contains DequeueInterface objects. If DequeueInterface is (as it appears to be) an interface specifying a double-ended queue, then those queues contains Disk objects. In other words, you have a List of Queues of Disks.
So if you iterate over the ArrayList, each entry is a queue. If you print the queue, then it's the toString() in the DequeueInterface implementation that will be called -- that seems to be a class named "LinkedDequeue" in your case. Based on what you're showing here, that class doesn't override toString() at all, so you just get the version from Object that returns "LinkedDequeue@98739873".
But it looks like you want to print the Disk objects in the queues. So you need to print each Disk in each Queue; in other words, you need TWO loops.
Pardon me, but I have to make something up here: let's hope that DequeueInterface implements Iterable and therefore has a method "iterator()" just like the ArrayList one, which iterates over all the items in the queue. If it doesn't then this code needs to be adjusted, of course.
Anyway, you want to do something like
This would print all the disks in all the queues. You might want to somehow add markers to divide the displays for the different queues; that's up to you.
I hope this helps.