slogo.instruction
Class If
java.lang.Object
slogo.language.GrammarElement
slogo.instruction.Instruction
slogo.instruction.If
public class If
- extends Instruction
Method Summary |
java.lang.Object |
evaluate(Context c)
Evaluate the IF instruction in a Context. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
myList
protected StrictInstructionList myList
cond
protected GrammarElement cond
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 executedsil
- strict instruction list that is the body
If
public If(ConditionalInstruction cond,
StrictInstructionList sil)
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