46 lines
866 B
Java
46 lines
866 B
Java
public class DigitalInput {
|
|
private boolean value = false;
|
|
|
|
public DigitalInput(final boolean value) {
|
|
setValue(value);
|
|
}
|
|
|
|
public DigitalInput(final LogicGate gate) {
|
|
setValue(gate);
|
|
}
|
|
|
|
public DigitalInput(final int value) {
|
|
setValue(value);
|
|
}
|
|
|
|
public DigitalInput(final char value) {
|
|
setValue(value);
|
|
}
|
|
|
|
/**
|
|
* default value is false!
|
|
*/
|
|
public DigitalInput() {
|
|
}
|
|
|
|
public boolean getValue() {
|
|
return value;
|
|
}
|
|
|
|
public void setValue(boolean value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public void setValue(LogicGate gate) {
|
|
this.value = gate.getOutput(); // todo validation stuff
|
|
}
|
|
|
|
public void setValue(int value) {
|
|
this.value = value > 0;
|
|
}
|
|
|
|
public void setValue(char value) {
|
|
this.value = value == 'H';
|
|
}
|
|
}
|