⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 booleancondition.java

📁 JAVA实现的有限状态自动机。该软件适合Linux环境下安装运行。
💻 JAVA
字号:
/***************************************************************************** * net.openai.fsm.BooleanCondition ***************************************************************************** * @author  JC on E * @date    9/18/2000 * 2001 OpenAI Labs *****************************************************************************/package net.openai.util.fsm;/** * BooleanCondition class */public final class BooleanCondition extends Condition {    /** Our target boolean value. */    private boolean targetValue = true;    /**     * Constructs a BooleanCondition with it's target value set to     * <code>true</code>.     */    public BooleanCondition() {    }    /**     * Constructs a BooleanCondition with the given target value.     *     * @param target The boolean value that will satisfy this condition.     */    public BooleanCondition(boolean target) {	targetValue = target;    }    /**     * Constructs a BooleanCondition with the given target value.     *     * @param target The Boolean value that will satisfy this condition.     */    public BooleanCondition(Boolean target) {	targetValue = target.booleanValue();    }    /**     * Constructs a BooleanCondtion with it's target value set to      * <code>true</code> and it's target state set to the given state.     *     * @param targetState The target state for this BooleanCondition.     */    public BooleanCondition(State targetState) {	super(targetState);    }    /**     * Constructs a BooleanCondition with the given target value and the     * given target state.     *     * @param targetState The target state for this BooleanCondtion.     * @param target      The boolean value that will satisfy this condition.     */    public BooleanCondition(State targetState, boolean target) {	super(targetState);	targetValue = target;    }    /**     * Constructs a BooleanCondition with the given target value.     *     * @param targetState The target state for this BooleanCondition.     * @param target      The Boolean value that will satisfy this condition.     */    public BooleanCondition(State targetState, Boolean target) {	super(targetState);	targetValue = target.booleanValue();    }    /**     * Sets the target boolean value that will satisfy this condition.     *     * @param target The boolean value that will satisfy this condition.     */    public final void setTarget(boolean target) {	targetValue = target;    }    /**     * Sets the target Boolean value that will satisfy this condition.     *     * @param target The Boolean value that will satisfy this condition.     */    public final void setTarget(Boolean target) {	targetValue = target.booleanValue();    }    /**     * Returns the target value that will satisfy this condition.     *     * @return The target value that will satisfy this condition.     */    public final boolean getTarget() {	return targetValue;    }    /**     * Called to check if the conditional meets the criteria defined by this     * state.  This is the only method to implement in order to used this     * interface.     *     * @param conditional The object to check.     * @return Implementors should return <code>true</code> if this condition     *         is met by the Object <code>conditional</code> and     *         <code>false</code> otherwise.     */    public final boolean satisfiedBy(Object conditional) {	if(conditional instanceof Boolean)	    return (((Boolean)conditional).booleanValue() == targetValue);	return false;    }    /*    public static class MyState extends State {	String name = "unnamed";	public MyState(String name) {	    if(name != null)		this.name = name;	}	public void enter(Object input) {	    System.out.println(name + " entered.");	}	public Object exit() {	    System.out.println(name + " exited.");	    return null;	}    }    public static void main(String args[]) {	MyState state1 = new MyState("State 1");	MyState state2 = new MyState("State 2");	MyState state3 = new MyState("State 3");	state1.addTransition(new BooleanCondition(true), state2);	state1.addTransition(new BooleanCondition(false), state3);	state2.addTransition(new BooleanCondition(true), state1);	state2.addTransition(new BooleanCondition(false), state1);	state3.addTransition(new BooleanCondition(true), state1);	state3.addTransition(new BooleanCondition(false), state1);	Machine machine = new Machine(state1);	try {	    machine.input(new Boolean(true));	    machine.input(new Boolean(false));	    machine.input(new Boolean(false));	    machine.input(new Boolean(true));	} catch(UnhandledConditionException uce) {	    uce.printStackTrace();	}    }    */}

⌨️ 快捷键说明

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