slogo.instruction
Class If

java.lang.Object
  extended by slogo.language.GrammarElement
      extended by slogo.instruction.Instruction
          extended by slogo.instruction.If

public class If
extends Instruction


Field Summary
protected  GrammarElement cond
           
protected  StrictInstructionList myList
           
 
Fields inherited from class slogo.language.GrammarElement
gelementsToValue
 
Constructor Summary
If(ConditionalInstruction cond, StrictInstructionList sil)
           
If(GrammarElement cond, StrictInstructionList sil)
          Constructs an If instruction that can be executed.
 
Method Summary
 java.lang.Object evaluate(Context c)
          Evaluate the IF instruction in a Context.
 java.lang.String toString()
           
 
Methods inherited from class slogo.instruction.Instruction
evaluateNumericExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myList

protected StrictInstructionList myList

cond

protected GrammarElement cond
Constructor Detail

If

public If(GrammarElement cond,
          StrictInstructionList sil)
Constructs an If instruction that can be executed.

Parameters:
cond - the condition for which the body should be executed
sil - strict instruction list that is the body

If

public If(ConditionalInstruction cond,
          StrictInstructionList sil)
Method Detail

evaluate

public java.lang.Object evaluate(Context c)
Evaluate the IF instruction in a Context. Executes the statements only if condition is not 0

Overrides:
evaluate in class Instruction
Parameters:
c - the Context for the evaluation
Returns:
the result of evaluating the if statement. Null if the statement is not executed.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a String representing this instruction