the problem is with your addGuest() method, not your toString.
I understand that when addGuest() is called it only makes new nodes but doesn't point to the next new node that is created. I don't really know how to go about doing this.
I would alter it so you pass the constuctor the current head node.
Code:
public void addGuest(String name, int numGuests) {
head = new GuestListNode(head, name, numGuests);
}
Can't do this as you can see in the link I've posted, the constructro from GuestListNode does not take 3 arguments.
Also, toString() methods should generally not use a println anywhere - thats not their purpose.
It should do something like this:
Code:
public String toString() {
GuestListNode temp = head;
String s = "";
while(temp != null){
s += temp.getName() + " " + temp.getNumGuests() + "\n";
temp = temp.getNext();
}
return s;
}