import objectdraw.*;

/**
 * Representation for a constant regarded as an arithmetic expression
 * 
 * @author Russell C. Bjork 
 * @version March 20, 2008
 */
public class Constant extends Node implements Expression
{
    private double value;   // The value of this constant
    
    /** Constructor
     * 
     *  @param value the value of this constant
     */
    public Constant(double value) {
        this.value = value;
    }
    
    // Methods required by the Expression interface
    
    public String toString() {
        return "" + value;
    }
    
    public double evaluate(double x) {
        return value;
    }
    
    public Expression derivative() {
        return new Constant(0);
    }
    
    public Expression simplify() {
        return this;
    }
    
    public void draw(double x, double y, double width, DrawingCanvas canvas) {
        drawNode("" + value, x, y, width, canvas);
    }
}
