2020-04-13 10:56:58 +00:00
|
|
|
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);
|
2020-04-14 09:01:51 +00:00
|
|
|
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);
|
2020-04-14 09:01:51 +00:00
|
|
|
if (inputvals.length > 8)
|
|
|
|
throw (new TooManyInputsException());
|
2020-04-13 09:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean getOutput() {
|
|
|
|
boolean state = getInput(0).getValue();
|
2020-04-13 10:56:58 +00:00
|
|
|
for (int i = 1; i < getInputNumber(); i++) {
|
2020-04-13 09:14:15 +00:00
|
|
|
state |= getInput(i).getValue();
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|