Files
LogicGates/eu.heili/OrGate.java
T

23 lines
588 B
Java
Raw Normal View History

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