/**
 * Implication implements logical implications
 */
public class Implication implements Predicate {
 
  // antecent and consequent are the first and second predicates
  // of the implication
  private Predicate antecedent, consequent;
  
  public Implication (Predicate p, Predicate q) {
    antecedent = p;
    consequent = q;
  }
  
  /**
   * Implication.of x is false exactly when the antecedent is true of
   * x and the consequent is false of x.
   * @param x is the object being evaluated by antecedent and predicate
   * @return false iff antecedent.of(x) is true but consequent.of(x) is false.
   */
  public boolean of(Object x) {
    return !antecedent.of(x) || consequent.of(x);
  }
}
