ANDObserver.java 969 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * CertainTrust Demonstrator in Java
  3. *
  4. * The ANDObserver is used to update the result of the AND operation
  5. * when the operands change and display the result in the result HTI.
  6. *
  7. * @author Florian Volk <florian.volk@cased.de>
  8. */
  9. import java.util.Observable;
  10. import java.util.Observer;
  11. import CertainTrust.CertainTrust;
  12. public class ANDObserver implements Observer {
  13. private CertainTrust Operand1;
  14. private CertainTrust Operand2;
  15. private CertainTrust Result;
  16. public ANDObserver(CertainTrust Operand1, CertainTrust Operand2, CertainTrust Result) {
  17. this.Operand1 = Operand1;
  18. this.Operand2 = Operand2;
  19. this.Result = Result;
  20. }
  21. @Override
  22. public void update(Observable arg0, Object arg1) {
  23. // calculate the result of the AND operation and update the Result CertainTrust data object
  24. CertainTrust ANDResult = this.Operand1.AND(this.Operand2);
  25. this.Result.setF(ANDResult.getF());
  26. this.Result.setTC(ANDResult.getT(), ANDResult.getC());
  27. }
  28. }