aima.core.agent.impl.aprog.simplerule.ANDCondition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
The newest version!
package aima.core.agent.impl.aprog.simplerule;
import aima.core.agent.impl.ObjectWithDynamicAttributes;
/**
* Implementation of an AND condition.
*
* @author Ciaran O'Reilly
*
*/
public class ANDCondition extends Condition {
private Condition left;
private Condition right;
public ANDCondition(Condition leftCon, Condition rightCon) {
assert (null != leftCon);
assert (null != rightCon);
left = leftCon;
right = rightCon;
}
@Override
public boolean evaluate(ObjectWithDynamicAttributes p) {
return (left.evaluate(p) && right.evaluate(p));
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
return sb.append("[").append(left).append(" && ").append(right)
.append("]").toString();
}
}