public NOT(LogicGate input) { previous_1 = input; previous_2 = null; previous_1.StatusChange += OutputChange; Output = !previous_1.Output; }
public NAND(LogicGate input1, LogicGate input2) { previous_1 = input1; previous_2 = input2; previous_1.StatusChange += OutputChange; previous_2.StatusChange += OutputChange; Output = !(previous_1.Output && previous_2.Output); }
public OR(LogicGate input1, LogicGate input2) { previous_1 = input1; previous_2 = input2; previous_1.StatusChange += OutputChange; previous_2.StatusChange += OutputChange; Output = previous_1.Output || previous_2.Output; }
public static LogicGate CreateGate(LogicGate input1, LogicGate input2, Type name) { switch (name) { case Type.OR: return(new OR(input1, input2)); case Type.NOR: return(new NOR(input1, input2)); case Type.AND: return(new AND(input1, input2)); case Type.NAND: return(new NAND(input1, input2)); default: throw new ArgumentException(); } }
public static LogicGate CreateGate(LogicGate input) { return(new NOT(input)); }