Polynomial3

Polynomial3 - / a sample polynomial class, with a main()...

This preview shows pages 1–3. Sign up to view the full content.

// a sample polynomial class, with a main() for testing public class Polynomial3 { private LinkedList lst; private int numTerms; private int degree; Polynomial3() { lst = new LinkedList(); numTerms = 0; degree = 0; } public LinkedList getList() { return lst; } public int getDegree() { return degree; } public int getTermNum() { return numTerms; } public void setDegree(int d) { degree = d; } public void setTermNum(int t) { numTerms = t; } // print a poly object in a readable format public void printPoly() { if (lst.isEmpty()) { System.out.print("numTerms = " + numTerms + "; degree = " + degree + "; "); System.out.println("F(x) = 0"); } else { System.out.print("numTerms = " + numTerms + "; degree = " + degree + "; " + "F(x) = "); Term tm = new Term(); int exponent; int coefficient; LinkedListItr itr = lst.first(); tm = (Term)(itr.retrieve());

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
exponent = tm.getExponent(); coefficient = tm.getCoefficient(); System.out.print(coefficient + "x^" + exponent); itr.advance(); for(; !itr.isPastEnd(); itr.advance())
This is the end of the preview. Sign up to access the rest of the document.

Polynomial3 - / a sample polynomial class, with a main()...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online