2020-04-13 09:14:15 +00:00
|
|
|
public class Main {
|
2020-04-10 16:35:47 +00:00
|
|
|
public static void main(String[] args) {
|
2020-04-14 09:01:51 +00:00
|
|
|
// teacher example:
|
2020-04-13 09:14:15 +00:00
|
|
|
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);
|
|
|
|
|
2020-04-14 09:01:51 +00:00
|
|
|
|
|
|
|
/** some definition tests with better syntax (; */
|
2020-04-13 10:56:58 +00:00
|
|
|
AndGate gt = new AndGate(
|
2020-04-14 09:01:51 +00:00
|
|
|
new DigitalInput(0),
|
2020-04-13 10:56:58 +00:00
|
|
|
new DigitalInput(true),
|
|
|
|
new DigitalInput(o1),
|
2020-04-14 09:01:51 +00:00
|
|
|
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 **/
|
|
|
|
|
2020-04-14 09:29:26 +00:00
|
|
|
final boolean x = false;
|
|
|
|
final boolean y = true;
|
2020-04-14 09:01:51 +00:00
|
|
|
|
|
|
|
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 **/
|
2020-04-14 09:29:26 +00:00
|
|
|
final boolean xx = true;
|
|
|
|
final boolean yy = false;
|
2020-04-13 09:23:57 +00:00
|
|
|
|
2020-04-14 09:01:51 +00:00
|
|
|
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());
|
2020-04-10 16:35:47 +00:00
|
|
|
}
|
|
|
|
}
|