Printing Information in a node
Quote:
Solved.
The access that was being used to get to things was backasswards.
To many .nexts and not enough veriables.
I'll be sure to tell the people in the class about it.
Ok, We've got an assignment, where you have to print names in a particular month.
Yes we've done the assignment with arrays and I got that program working fine. Now we're using a linked list. and I have a basic code someone else wrote and have been using it as a jumping base and help to set up my own algorithem and such things.
Now, I have sucessfully gotten most of the program working. The problem is this...
public void printMonth(int Month)
{
UnorderedLinkedList<ExtPerson>.LinkedListIterator< ExtPerson> i = list.iterator();
//using month make a loop
while(i.hasNext())
{
if(i.next().getMonth()== Month)
{
System.out.println(i.next().getLastName()+ " " + i.next().getFirstName());
}
}
What happens is insted of printing the first and last name of the person who's birthday is in that month, its printing four different names from four different nodes
and I have tried changing .next to .info sense info is the name of the half of the node that has the actuall information in it but then it doesn't complie.
So I'm asking for any suggestions as to what to do insted. I realize part of what its doing is it's going to the information in the link beyond the one its supposed to be doing, I figured that out with the straight up print method. This one though has me stumped.