/* * Default constructor.Although there are two standard inputs, one of them might be equal to null * (for example:NOT-gate) */ public LogicGate(StatePoint A, StatePoint B) { output = new StatePoint(0,false); A.setOwner(this); B.setOwner(this); this.input1 = A; this.input2 = B; }
public void disconnectTwoPoints(StatePoint A, StatePoint B) { int i = 0; bool mustRun = true; while (i < connections.Count && mustRun) { Connection c = connections.ElementAt(i); if (c.getStartPoint().Equals(A) && c.getEndPoint().Equals(B)) { connections.Remove(c); mustRun = false; } //Trying to save some procedures. } }
public void connectTwoPoints(StatePoint A, StatePoint B) { Connection c = new Connection(A, B); connections.Add(c); }
public void addOutputPort(StatePoint A) { outputPorts.Add(A); }
//Methods to add or remove input/output ports and logic gates public void addInputPort(StatePoint A) { inputPorts.Add(A); }
public void removeOutputPort(StatePoint A) { outputPorts.Remove(A); }
public void removeInputPort(StatePoint A) { inputPorts.Remove(A); }
public Connection(StatePoint startPoint, StatePoint endPoint) { this.startPoint = startPoint; this.endPoint = endPoint; }