1 package era.mi.logic.components;
5 import era.mi.logic.types.Bit;
6 import era.mi.logic.wires.Wire.ReadEnd;
7 import era.mi.logic.wires.Wire.ReadWriteEnd;
10 * This class models a simple on/off (ONE/ZERO) switch for user interaction.
12 * @author Christian Femers
15 public class ManualSwitch implements Component
17 private ReadWriteEnd output;
20 public ManualSwitch(ReadWriteEnd output)
22 if (output.length() != 1)
23 throw new IllegalArgumentException("Switch output can be only a single wire");
27 public void switchOn()
32 public void switchOff()
42 public void setState(boolean isOn)
44 if (this.isOn == isOn)
47 output.feedSignals(getValue());
57 return isOn ? Bit.ONE : Bit.ZERO;
61 public List<ReadEnd> getAllInputs()
67 public List<ReadWriteEnd> getAllOutputs()
69 return List.of(output);