package arrayPoly; /** * Represents the polynomial abstraction. Holds the coefficient. Has two concrete * subclasses, ConstPoly and NonConstPoly, to form the composite pattern. The client * should only know about APolynomial and nothing about its subclasses. A factory, * PolyFactory, is used to manufacture polynomial objects for the client. *
 * Copyright 2000, by Dung X. Nguyen, All rights reserved.
 * 
* @author Dung X. Nguyen * @since 02/16/2000 * @dependency arrayPoly.IVisitor uses */ public abstract class APolynomial { /** * The leadin coefficient. */ private double _coef; /** * @return the leading coefficient of the referencing polynomial. */ public double getLeadCoef() { return _coef; } /** * @return the degree (or order) of the referencing polynomial. */ public abstract int getDegree (); /** * @return the lower ordered polynomial of the referencing polynomial, if any. * @exception throws NoSuchElementException if the referencing polynomial is a constant. */ public abstract APolynomial getLowerPoly (); /** * Hook to perform all visitor polynomial algorithms. * @param algo an algorithm on Polynomials. * @param input the input needed by algo. * @param owner the context of this abstract polynomial type. * @return the output object for algo. */ public abstract Object execute(IVisitor algo, Object input); /** * Returns the String representation as the lowest order term in a higher order polynomial. * Helper for toString() method. */ protected abstract String toString4LowerPoly (); }