/** PolynomialD1.java defines a degree 1 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, 1 +2x, 1 -2x are all ok. */package ann.math.polynomial;import ann.util.Controller;import java.util.StringTokenizer;public class PolynomialD1 extends PolynomialD0{ /** Default constructor  *  Postcondition: myB == 0.0 && myA == 0.0.  */ public PolynomialD1() {   super();   myB = 0.0; } /** Construct from double  *  Receive:       double aValue, double bValue.  *  Postcondition: myA == aValue && myB == bValue.  */ public PolynomialD1(double aValue, double bValue) {   super(aValue);   myB = bValue; } /** Construct from String  *  Receive:       String polyString.  *  Precondition:  strPolyD1 is of the form "a + bx" or "a + bX",  *                  where a and b are numeric values.  *  Postcondition: myA == a && myB == b.  */ public PolynomialD1(String polyString) {   super(polyString);              // process A term (using myTokenizer)   myB = getNextCoefficient();     // process B term (same way) }  /* B-attribute accessor  * Return: myB.  */ public double getB() {   return myB; } /** B-attribute mutator  *  Receive:       double newB.  *  Postcondition: myB == newB.  */ public void setB(double newB) {   myB = newB; } /** String converter (output)  *  Return: the String equivalent to myA.  */ public String toString() {   if (myB < 0)     return super.toString() + " - " + Double.toString(-myB) + "x";   else     return super.toString() + " + " + Double.toString(myB) + "x"; } //--- Attribute variable --- private double myB;}