public static void connect_Devices(ElectricalDevice target, ElectricalDevice device)
 {
     target.ConnectedDevices.Add(device);
     device.ConnectedDevices.Add(target);
     target.seek_network();
     device.seek_network();
 }
        static void Main(string[] args)
        {
            allDevs = new List <ElectricalDevice>();
            ElectricalDevice dev0 = new ElectricalDevice(1000); allDevs.Add(dev0);
            ElectricalDevice dev1 = new ElectricalDevice(-650); allDevs.Add(dev1);
            ElectricalDevice dev2 = new ElectricalDevice(-50); allDevs.Add(dev2);
            ElectricalDevice dev3 = new ElectricalDevice(-100); allDevs.Add(dev3);
            ElectricalDevice dev4 = new ElectricalDevice(-150); allDevs.Add(dev4);
            ElectricalDevice dev5 = new ElectricalDevice(-200); allDevs.Add(dev5);

            print_DeviceInfo();
            connect_Devices(dev0, dev1);
            print_DeviceInfo();
            connect_Devices(dev1, dev2);
            print_DeviceInfo();
            disconnect_Devices(dev0, dev1);
            print_DeviceInfo();
            connect_Devices(dev2, dev3);
            print_DeviceInfo();
            connect_Devices(dev0, dev1);
            print_DeviceInfo();
            connect_Devices(dev3, dev4);
            print_DeviceInfo();
            connect_Devices(dev4, dev5);
            print_DeviceInfo();
        }
예제 #3
0
 public void add_connectedDevice(ElectricalDevice newDevice)
 {
     //if (!connectedDevices.Contains(newDevice) )
     //{
     connectedDevices.Add(newDevice);
     //}
 }
 public static void disconnect_Devices(ElectricalDevice target, ElectricalDevice device)
 {
     if (!target.ConnectedDevices.Contains(device))
     {
         return;
     }
     else
     {
         target.ConnectedDevices.Remove(device);
         device.ConnectedDevices.Remove(target);
         target.seek_network();
         device.seek_network();
     }
 }
예제 #5
0
 public bool remove_connectedDevice(ElectricalDevice oldDevice)
 {
     if (connectedDevices.Contains(oldDevice))
     {
         connectedDevices.Remove(oldDevice);
     }
     if (connectedDevices.Contains(oldDevice))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }