Beispiel #1
0
        /// <summary>
        /// This function deletes the selected gate along with all of its connection from the circuit
        /// It deletes all connection of that gate first before finally deleting the gate itself
        /// </summary>
        /// <param name="gate">The gate to be deleted</param>
        /// <returns>True if the gate is deleted</returns>
        public bool deleteGate(Gate gate)
        {
            setUndoList();
            this.redoList.Clear();
            List <Connection> temp = gate.getListOfConnections();
            int count = temp.Count();

            for (int i = 0; i < count; i++)
            {
                if (temp[i] != null)
                {
                    if (temp[i].isFirstGate(gate))
                    {
                        Gate       temp2 = temp[i].getSecondGate();
                        Connection Cx    = temp[i];
                        do
                        {
                            Cx = temp2.inputConnectionInvalid(Cx);
                            if (Cx != null)
                            {
                                temp2 = Cx.getSecondGate();
                            }
                            else
                            {
                                temp2.calcValue();
                            }
                        }while (Cx != null);
                    }
                    deleteConnection(temp[i]);
                }
            }

            gateList.Remove(gate);
            return(true);
        }
Beispiel #2
0
 //Copy Constructor
 /// <summary>
 /// Copy Constructor of the Gate Class
 /// </summary>
 /// <param name="g">The gate object to be copied</param>
 public Gate(Gate g)
 {
     Connected  = new List <Connection>();
     this.row   = g.getRow();
     this.col   = g.getColumn();
     this.Value = g.calcValue();
 }
Beispiel #3
0
 /// <summary>
 /// This function return the value of the connection, which is depended on the first gate
 /// </summary>
 /// <returns></returns>
 public int getValue()
 {
     return(first.calcValue());
 }