slogo.expression
Class Expression

java.lang.Object
  extended by slogo.language.GrammarElement
      extended by slogo.expression.Expression
Direct Known Subclasses:
Number, Variable

public abstract class Expression
extends GrammarElement

The base class of all arithmetic expressions, the evaluate method uses the hook/template method value to return a Double value, the template method returns a double.

Author:
Owen Astrachan

Field Summary
 
Fields inherited from class slogo.language.GrammarElement
gelementsToValue
 
Constructor Summary
Expression()
           
 
Method Summary
 java.lang.Double evaluate(Context c)
          Evaluate this language construct in some context.
abstract  double value(Context c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expression

public Expression()
Method Detail

evaluate

public java.lang.Double evaluate(Context c)
Description copied from class: GrammarElement
Evaluate this language construct in some context. The evaluation may have side-effects, e.g., moving a turtle.

Specified by:
evaluate in class GrammarElement
Parameters:
c - context in which the evaluation takes place
Returns:
the result of evaluating the construct

value

public abstract double value(Context c)