/***********************************************************
 * Clause data structre 
 * Updated by Mark Goadrich 2/16/2008
 *
 * The Clause class holds three literals, A, B, C, and 
 * three booleans denoting the status of their negation.  
 * Clauses consist of a disjunction of literals.  The clause
 * is true when at least one of its literals is true.
 * In logic, clauses are written as (A v ~B v C)
 ***********************************************************/
public class Clause {
    private Literal[] lits = new Literal[3];   // The literals in our clause
    
    // the constructor initializes all the data members
    public Clause(Literal A, Literal B, Literal C) {
	lits[0] = A;
	lits[1] = B;
	lits[2] = C;
    }

    // returns the truth value of the clause. (disjunction of literals)
    public boolean findTValue() {
	for (int i = 0; i < lits.length; i++) {
	    if (lits[i].findTValue()) {
		return true;
	    }
	}
	return false;
    } 

    // prints out the clause in a human-readable form...(A v B v ~C)
    public String toString() {
	return "("+ lits[0] + " v " + lits[1] + " v " + lits[2] + ")";
    }
}
