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);
}