public class TestAnd { /** * @param args */ public static void main(String[] args) { AndGate gate1 = new AndGate(); AndGate gate2 = new AndGate(); Wire w1 = new Wire(); Wire w2 = new Wire(); Wire w3 = new Wire(); Wire w4 = new Wire(); Wire w5 = new Wire(); gate1.addInput(w1); gate1.addInput(w2); gate1.addOutput(w3); gate2.addInput(w3); gate2.addInput(w4); gate2.addOutput(w5); w4.setState(true); w1.setState(true); w2.setState(true); System.out.println("w5.state = " + w5.getState()); w1.setState(true); w2.setState(false); System.out.println("w5.state = " + w5.getState()); w1.setState(false); w2.setState(true); System.out.println("w5.state = " + w5.getState()); w1.setState(false); w2.setState(false); System.out.println("w5.state = " + w5.getState()); /* output w5.state = true w5.state = false w5.state = false w5.state = false */ } }