package funpoly; import funpoly.visitor.IVisitor; /** * 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. * @author Dung X. Nguyen * @since 12/24/99 * @dependency funpoly.visitor.IVisitor uses */ public abstract class APolynomial { protected int _coef; /** * @return the leading coefficient of the referencing polynomial. */ public int 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 (); /** * @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); /** * Helper for toString() method. */ abstract String toStringHelp (); }