LogicGates/eu.heili/AndGate.java
lukas-heiligenbrunner 574c58f1c5 added nand not nor enxor exor gates
and two bsp from teacher.
2020-04-14 11:01:51 +02:00

23 lines
591 B
Java

public class AndGate extends LogicGate {
public AndGate(final int inputnr) {
super(inputnr);
if (inputnr > 8)
throw (new TooManyInputsException());
}
public AndGate(final DigitalInput... inputvals) {
super(inputvals);
if (inputvals.length > 8)
throw (new TooManyInputsException());
}
@Override
public boolean getOutput() {
boolean state = getInput(0).getValue();
for (int i = 1; i < getInputNumber(); i++) {
state &= getInput(i).getValue();
}
return state;
}
}