/****************************************************************
 * Literal data structure
 * Updated by Mark Goadrich 2/16/2008
 * 
 * This class contains a Propositional Symbol and a boolean
 * value for the status of negation.  Literals are a slight extention
 * over PropSymbol, in that they allow the symbol to be negated.
 ***************************************************************/
public class Literal {
    private PropSymbol prop;    // holds the Propositional Symbol
    private boolean negation;   // holds the status of the negation

    // the constructor initializes the values for prop and negation
    public Literal(PropSymbol prop, boolean negation) {
	this.prop = prop;
	this.negation = negation;
    }

    // returns the truth value for the Literal.  If negation is true,
    // then return the negation of the PropSymbol, otherwise return 
    // the value of the PropSymbol.
    public boolean findTValue() {
	if(negation) {
	    return !prop.booleanValue();
	} else {
	    return prop.booleanValue();
	}
    }

    // returns a String for easy printing of the literal.  This sticks
    // a squiggle on the front of the PropSymbol to denote negation.
    public String toString() {
	String temp = "";
	if(negation) {
	    temp = "~";
	}
	temp += prop.getIndex();
	return temp;
    }
}
