public class Term {
private int coe;//Stores coefficient
private int exp;//Stores exponent
public Term(int coef, int expo)
{
coef = coe;
expo = exp;
}
public int getCoe()
{
return coe;
}
public int getExp()
{
return exp;
}
}
我正在尝试将给定的对象传递给ints对象a,然后将它们添加到list被Term调用的对象中poly。例如,让coeff = 3和expo = 2。我想将 3 和 2 存储到 list callpoly中。但是,我的对象a没有存储 3 和 2,两个参数都显示为 0。
public void insert(int coeff, int expo) {
Term a = new Term(coeff, expo);// Creates a new Term object with passed #'s
poly.add(a);
}