001    package aima.basic.simplerule;
002    
003    import aima.basic.ObjectWithDynamicAttributes;
004    
005    /**
006     * Implementation of an OR condition.
007     *
008     */
009    
010    /**
011     * @author Ciaran O'Reilly
012     * 
013     */
014    public class ORCondition extends Condition {
015            private Condition left;
016    
017            private Condition right;
018    
019            public ORCondition(Condition aLeftCon, Condition aRightCon) {
020                    assert (null != aLeftCon);
021                    assert (null != aRightCon);
022    
023                    left = aLeftCon;
024                    right = aRightCon;
025            }
026    
027            @Override
028            public boolean evaluate(ObjectWithDynamicAttributes p) {
029                    return (left.evaluate(p) || right.evaluate(p));
030            }
031    
032            @Override
033            public String toString() {
034                    StringBuffer sb = new StringBuffer();
035    
036                    return sb.append("[").append(left).append(" || ").append(right).append(
037                                    "]").toString();
038            }
039    }