LogicGates/eu.heili/DigitalInput.java

46 lines
860 B
Java
Raw Normal View History

2020-04-13 09:14:15 +00:00
public class DigitalInput {
private boolean value = false;
2020-04-13 12:36:06 +00:00
public DigitalInput(final boolean value) {
setValue(value);
}
public DigitalInput(LogicGate gate) {
setValue(gate);
}
2020-04-13 12:36:06 +00:00
public DigitalInput(final int value) {
setValue(value);
}
2020-04-13 12:36:06 +00:00
public DigitalInput(final char value) {
setValue(value);
2020-04-13 09:14:15 +00:00
}
/**
* default value is false!
*/
public DigitalInput() {
}
public boolean getValue() {
return value;
}
2020-04-13 09:14:15 +00:00
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) {
2020-04-13 10:48:15 +00:00
this.value = value > 0;
2020-04-13 09:14:15 +00:00
}
public void setValue(char value) {
2020-04-13 10:48:15 +00:00
this.value = value == 'H';
2020-04-13 09:14:15 +00:00
}
}