/** * CertainTrust Demonstrator in Java * * The ANDObserver is used to update the result of the AND operation * when the operands change and display the result in the result HTI. * * @author Florian Volk */ import java.util.Observable; import java.util.Observer; import CertainTrust.CertainTrust; public class ANDObserver implements Observer { private CertainTrust Operand1; private CertainTrust Operand2; private CertainTrust Result; public ANDObserver(CertainTrust Operand1, CertainTrust Operand2, CertainTrust Result) { this.Operand1 = Operand1; this.Operand2 = Operand2; this.Result = Result; } @Override public void update(Observable arg0, Object arg1) { // calculate the result of the AND operation and update the Result CertainTrust data object CertainTrust ANDResult = this.Operand1.AND(this.Operand2); this.Result.setF(ANDResult.getF()); this.Result.setTC(ANDResult.getT(), ANDResult.getC()); } }