Exemple #1
0
        static void Main(string[] args)
        {
            ElectricalNetwork net0 = new ElectricalNetwork(1);

            net0.add_connectedDevice(new ElectricalDevice(100, 1));
            net0.add_connectedDevice(new ElectricalDevice(-30, 2));
            net0.print_connectedDevices();
            Console.WriteLine("Total power on network = {0}", net0.get_powerSum());
        }
 public void seek_network()
 {
     Console.WriteLine("BEGIN seek_network()");
     Network.Devices.Remove(this);
     if (ConnectedDevices.Count == 0)
     {
         Network = new ElectricalNetwork();
     }
     else
     {
         if (Network != ConnectedDevices[0].Network)
         {
             Network = ConnectedDevices[0].Network;
         }
     }
 }
 public ElectricalDevice(int powerOutput)
 {
     Network          = new ElectricalNetwork();
     Power            = powerOutput;
     connectedDevices = new List <ElectricalDevice>();
 }
 public ElectricalDevice()
 {
     Power            = 0;
     Network          = new ElectricalNetwork();
     connectedDevices = new List <ElectricalDevice>();
 }