jelan.elan.expression
Class Variable

java.lang.Object
  extended by jelan.elan.GrammarElement
      extended by jelan.elan.expression.Expression
          extended by jelan.elan.expression.Variable
All Implemented Interfaces:
java.lang.Comparable<Variable>

public class Variable
extends Expression
implements java.lang.Comparable<Variable>

A variable stores a value and can be used in an expression. Clients can create many objects representing a variable, say "X", but each of these maps to the same object so that there is a common value for any occurrence of a named-variable

See Also:
VariableFactory

Constructor Summary
Variable(java.lang.String name)
           
 
Method Summary
 int compareTo(Variable v)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Double evaluate(Context c)
          Evaluate this language construct in some context.
 java.lang.String toString()
           
 double value(Context c)
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

public Variable(java.lang.String name)
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.

Overrides:
evaluate in class Expression
Parameters:
c - context in which the evaluation takes place
Returns:
the result of evaluating the construct

value

public double value(Context c)
Specified by:
value in class Expression

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(Variable v)
Specified by:
compareTo in interface java.lang.Comparable<Variable>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object