public class PolyClient { /** * A few simple test cases. */ public static void main (String[] args) { APolynomial pc0 = new ConstPoly (0.0); // pc0 == 0. APolynomial pc1 = new ConstPoly (-1.0); // pc1 == -1. APolynomial p1 = new NonConstPoly (-5.0, 3, pc0); // p1 == -5x^3. APolynomial p2 = new NonConstPoly (2.0, 5, p1); // p2 == 2x^5 - 5x^3. APolynomial p3 = new NonConstPoly (-4.0, 6, p2); // p3 = -4x^6 + 2x^5 - 5x^3. APolynomial p4 = new NonConstPoly (3.0, 2, pc1); // p4 = 3x^2 - 1. APolynomial p5 = new NonConstPoly (-2.0, 5, p4); // p5 = -2x^5 + 3x^2 -1. System.out.println ("0 = " + pc0); System.out.println ("-1 = " + pc1); System.out.println ("3x^2 - 1 = " + p4); System.out.println ("-5x^3 + 0 = " + p1); System.out.println ("2x^5 - 5x^3 + 0 = " + p2); System.out.println ("-4x^6 + 2x^5 - 5x^3 + 0 = " + p3); System.out.println ("-4x^6 - 5x^3 + 3x^2 - 1 = " + p5.add (p3)); } }