AIMA.Core.Logic.Propositional.Algorithms.Model.visitBinarySentence C# (CSharp) Method

visitBinarySentence() public method

public visitBinarySentence ( BinarySentence bs, Object arg ) : Object
bs AIMA.Core.Logic.Propositional.Parsing.Ast.BinarySentence
arg Object
return Object
	public Object visitBinarySentence(BinarySentence bs, Object arg) {
		bool? firstValue = (bool?) bs.getFirst().accept(this, null);
		bool? secondValue = (bool?) bs.getSecond().accept(this, null);
		if (!firstValue.HasValue  || !secondValue.HasValue) {
			// strictly not true for or/and
			// -FIX later
			return null;
		} else {
			String op = bs.getOperator();
			if (op.Equals("AND")) {
                return firstValue.Value && secondValue.Value;
			} else if (op.Equals("OR")) {
                return firstValue.Value || secondValue.Value;
			} else if (op.Equals("=>")) {
                return !(firstValue.Value && !secondValue.Value);
            }
            else if (op.Equals("<=>"))
            {
				return firstValue.Equals(secondValue);
			}
			return null;
		}
	}