robotvalue.java

来自「是有关解释器的.用JAVA编写.可以解释一般的JAVA程序.」· Java 代码 · 共 53 行

JAVA
53
字号
public class RobotValue extends Value 
{
	private QueryRobot value;

    RobotValue() 
	{
        this.value = null;
    }

    RobotValue(QueryRobot robot) 
	{
        value = robot;
    }

    boolean isRobotRef() 
    {
        return true;
    }

    QueryRobot robotRef() 
    {
        return value;
    }

    boolean isOfType(String typeName) 
    {
        return typeName.equals("Robot");
    }

    Value isEqual(Value v) throws InterpreterException 
	{
        if (!v.isRobotRef())
            throw new InterpreterException(
                    "This type does not support equation.");

        return new BooleanValue(value == ((RobotValue) v).robotRef());
    }

    Value assign(Value v) throws InterpreterException 
	{
        if (!v.isRobotRef())
            throw new InterpreterException("wrong type.");

        this.value = ((RobotValue) v).robotRef();
        return this;
    }

    Value cloneValue() 
    {
        return new RobotValue(value);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?