while(counter != this.data.size()) {
for(int i=0; i <= p.data.size(); i++) {
double coefficient = first.getData().getCoefficient() * sec.getData().getCoefficient();
int degree = first.getData().getDegree() + sec.getData().getDegree();
Term current = new Term(coefficient,degree);
if(ans.data.isEmpty()) {
ans.data.addFirst(current);
}
else {
boolean found = false;
DNode<Term > tmp = ans.data.getFirst();
while(found != true) {
if(tmp.getData() == null) {
ans.data.addLast(current);
found = true;
}
else if(current.getDegree() > tmp.getData().getDegree()) {
ans.data.addBefore(current, tmp);
found = true;
}
else if(current.getDegree() == tmp.getData().getDegree()) {
double co = current.getCoefficient() * tmp.getData().getCoefficient();
int deg = current.getDegree() + tmp.getData().getDegree();
tmp.getData().setCoefficient(co);
tmp.getData().setDegree(deg);
found = true;
}
System.out.println("DID I GET HERE");
tmp = tmp.getNext();
}
System.out.println("DID I GET HERE2");
}
System.out.println("DID I GET HERE3");
sec = sec.getNext();
}
System.out.println("DID I GET HERE4");
first = first.getNext();
counter++;
}
我的代码甚至没有到达我到达这里的原因4,有人可以告诉我为什么吗? 我遇到了很多困难,因为该项目定于今天晚些时候发布,因此代码假定要乘以2个多项式