Sequence with linked list and Generics *2 Errors*
Hello! Ran the J-unit tests, runs 19/19 with 2 Errors located in my methods: addAll & concatenation.
I truly appreciate the help friends!
Code java:
public void addAll(LinkedSeq<E> addend)
{
if(addend == null)
{
throw new NullPointerException("addend is null");
}
********tail.setLink(addend.head);********(Seems it originates here)
//addend.head = this.tail;
tail = addend.tail;
//addend.tail = this.tail;
addend.cursor = null;
manyNodes += addend.manyNodes;
addend.tail = tail;
//if(addend.tail.getLink() != null)
//{
// addend.tail = addend.tail.getLink();
//}
}
And here's the second method
Code java:
public static <E> LinkedSeq<E> concatenation(LinkedSeq<E> s1, LinkedSeq<E> s2)
{
if((s1 == null) || (s2 == null))
{
throw new IllegalArgumentException ("concatenation: one argument is null");
}
LinkedSeq<E> answer = new LinkedSeq<E>();
****************answer.addAll(s1);*****************(Other trace)
answer.addAll(s2);
return answer;
}
Re: Sequence with linked list and Generics *2 Errors*