/** PolynomialD3.java defines a degree 3 polynomial class. *  Author:  Joel C. Adams *  Version: For Java: An Introduction to Computing 1/e.  All Rights Reserved. *  NOTE: Polynomial terms are white-space delimited. *  Examples: 1 + 2x - 3xx + 4xxx, 1 +2x -3xx +4xxx, are all ok. */package ann.math.polynomial;import ann.util.Controller;public class PolynomialD3 extends PolynomialD2{ /* Default constructor  * Postcondition: myA == 0.0 && myB == 0.0   *                 && myC == 0.0 && myD == 0.0.  */ public PolynomialD3() {   super();   myD = 0.0; } /* Construct from double  * Receive:       double aValue, double bValue, double cValue.  * Postcondition: myA == aValue && myB == bValue   *                  && myC == cValue && myD == dValue.  */ public PolynomialD3(double aValue, double bValue, double cValue, double dValue) {   super(aValue, bValue, cValue);   myD = dValue; } /** Construct from String  *  Receive:       String polyString.  *  Precondition:  strPolyD1 is of the form "a + bx + cxx + dxxx"   *                   or "a + bX + cXX + dXXX",  *                   where a, b, c, d are numeric values.  *  Postcondition: myA == a && myB == b   *                   && myC == c && myD == d.  */ public PolynomialD3(String polyString) {   super(polyString);               // process A, B, C terms (using myTokenizer)   myD = getNextCoefficient();      // process D term (same way) } /** D-attribute accessor  *  Return: myD.  */ public double getD() {   return myD; } /** C-attribute mutator  *  Receive:       double newD.  *  Postcondition: myD == newD.  */ public void setD(double newD) {   myD = newD; } /** String converter (output)  *  Return: the String equivalent to me.  */ public String toString() {   if (myD < 0)     return super.toString() + " - " + Double.toString(-myD) + "xxx";   else     return super.toString() + " + " + Double.toString(myD) + "xxx"; } private double myD;}