public class Main { public static void main(String[] args) { // teacher example: OrGate o1 = new OrGate(2); AndGate a2 = new AndGate(2); // Verbinde Eingang 0 mit dem Ausgang vom OR - Gate. a2.getInput(0).setValue(o1); // Setze Eingang 1 auf 1. a2.getInput(1).setValue(0); // Setze Eingang 0 auf 0. o1.getInput(0).setValue(0); // Setze Eingang 1 auf 1. o1.getInput(1).setValue(0); /** some definition tests with better syntax (; */ AndGate gt = new AndGate( new DigitalInput(0), new DigitalInput(true), new DigitalInput(o1), new DigitalInput('H') ); LogicGate or = new AndGate( new DigitalInput(0), new DigitalInput(1) ); System.out.println(or.getOutput()); LogicGate nor = new NandGate( new DigitalInput(0), new DigitalInput(1) ); /** bsp 1 **/ final boolean x = false; final boolean y = true; LogicGate s = new OrGate( new DigitalInput(new AndGate( new DigitalInput(new NotGate( new DigitalInput(x) )), new DigitalInput(y) )), new DigitalInput(new AndGate( new DigitalInput(x), new DigitalInput(new NotGate( new DigitalInput(y) )) )) ); LogicGate c = new AndGate( new DigitalInput(x), new DigitalInput(y) ); System.out.println("Bsp1"); System.out.println("output of c: " + c.getOutput()); System.out.println("output of s: " + s.getOutput()); /** bsp. 2 **/ final boolean xx = true; final boolean yy = false; LogicGate ss = new ExorGate( new DigitalInput(xx), new DigitalInput(yy) ); LogicGate cc = new AndGate( new DigitalInput(xx), new DigitalInput(yy) ); System.out.println("Bsp2"); System.out.println("output of c: " + cc.getOutput()); System.out.println("output of s: " + ss.getOutput()); } }