574c58f1c5
and two bsp from teacher.
23 lines
591 B
Java
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;
|
|
}
|
|
}
|