package poly.op; import poly.*; import poly.factory.*; /** * Adds host polynomial to a constant Double and returns the resulting sum * polynomial. Turn this into an anonymous inner class when adding a polynomial * to constant polynomial, IConstPoly, host. * @author Dung X. Nguyen * @since Copyright 2002 - DXN - All rights reserved */ public class AddDouble implements IPolyOp { IPolyFact _fact; public AddDouble(IPolyFact f) { _fact = f; } /** * @param poly a constant polynomial * @param inp a Double * @return IConstPoly representing the sum of poly and inp. */ public Object forConst (IConstPoly poly, Object inp) { return _fact.makeConstPoly(poly.getLeadCoef() + ((Double)inp).doubleValue ()); } /** * @param poly a non-constant polynomial * @param inp a Double * @return INCPoly representing the sum of poly and inp. */ public Object forNonConst(INCPoly poly, Object inp) { // recur on the lower polynomial of poly, make an appropriate sum // and return it. return null; // TO DO } }