/**
* Term models terms in a polynomial.
*
* @author Lyndon While
* @version 1.0
*/
public class Term
{
// the term = coefficient * x ^ exponent
private double coefficient;
private int exponent;
public Term(double c, int e)
{
coefficient = c;
exponent = e;
}
// returns the coefficient
public double getCoefficient()
{
return coefficient;
}
// returns the exponent
public int getExponent()
{
return exponent;
}
// returns the term as a simple String for display
// e.g. with coefficient = 2 and exponent = 1, return "+ 2.0 x^1"
public String displaySimple()
{
// TODO
String displaySimple = "+ c*x^e";
return displaySimple;
}
// returns the term as a String for display:
// see the sample file and the test program for the layout required
public String displayImproved()
{
// TODO
if (coefficient 0){
}
if (exponent > 0){
}
return displayImproved;
}
}