LogicGates/eu.heili/AndGate.java
2020-04-13 14:36:06 +02:00

21 lines
507 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);
}
@Override
public boolean getOutput() {
boolean state = getInput(0).getValue();
for (int i = 1; i < getInputNumber(); i++) {
state &= getInput(i).getValue();
}
return state;
}
}