LogicGates/eu.heili/OrGate.java

23 lines
588 B
Java
Raw Normal View History

public class OrGate extends LogicGate {
2020-04-13 12:36:06 +00:00
public OrGate(final int inputnr) {
2020-04-13 09:14:15 +00:00
super(inputnr);
if (inputnr > 8)
throw (new TooManyInputsException());
2020-04-13 09:14:15 +00:00
}
2020-04-13 12:36:06 +00:00
public OrGate(final DigitalInput... inputvals) {
2020-04-13 09:14:15 +00:00
super(inputvals);
if (inputvals.length > 8)
throw (new TooManyInputsException());
2020-04-13 09:14:15 +00:00
}
@Override
public boolean getOutput() {
boolean state = getInput(0).getValue();
for (int i = 1; i < getInputNumber(); i++) {
2020-04-13 09:14:15 +00:00
state |= getInput(i).getValue();
}
return state;
}
}