Java Reference
In-Depth Information
Figure 25.4. The Term hierarchy includes classes that are effectively Booleans.
The Equals class and the HasMoreMaterial class return null to indicate false. You can
create, for example, an Equals term that compares a variable to the constant value of
the unload buffer:
Constant ub = new Constant(c.lookup("UnloadBuffer1501"));
Term t = new Equals(m, ub);
You can use an instance of Equals as the conditional term in an IfCommand object.
An IfCommand object has a term, a body command, and an elseBody command. When it
executes, an IfCommand object executes its main body command unless its term evaluates
to null , in which case it executes its elseBody command:
package com.oozinoz.robot.interpreter;
import com.oozinoz.machine.*;
public class IfCommand extends Command
{
protected Term term;
protected Command body;
protected Command elseBody;
Search WWH ::




Custom Search