/*
 * Created on Apr 3, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package ps6;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author knorton
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SoftEquals extends Gate {
	private ArrayList inputs = null;
	
	public SoftEquals() {	
		this.inputs = new ArrayList();
	}
	
	public void addInputGate(Gate g) {
		this.inputs.add(g);
	}
	
	public void update() {
		Iterator i = this.inputs.iterator();
		Gate g = (Gate)i.next();
		
		double p0 = g.getValue().getP(0);
		double p1 = g.getValue().getP(1);
		
		while (i.hasNext()) {
			g = (Gate)i.next();
			p0 *= g.getValue().getP(0);
			p1 *= g.getValue().getP(1);
		}
		
		this.setResult(new Message(p0,p1));
	}
}
