Beispiel #1
0
        static void Main(string[] args)
        {
            Generator generator = new Generator()
            {
                GeneratedPower = 1000
            };
            ConsumptionDevice consumptionDevice1 = new ConsumptionDevice()
            {
                ConsumptionPower = 700
            };
            ConsumptionDevice consumptionDevice2 = new ConsumptionDevice()
            {
                ConsumptionPower = 700
            };
            ConsumptionDevice consumptionDevice3 = new ConsumptionDevice()
            {
                ConsumptionPower = 700
            };
            ConsumptionDevice consumptionDevice4 = new ConsumptionDevice()
            {
                ConsumptionPower = 700
            };

            generator.PlugDevice(consumptionDevice1);
            consumptionDevice1.PlugDevice(consumptionDevice2);
            consumptionDevice2.PlugDevice(consumptionDevice3);
            consumptionDevice3.PlugDevice(consumptionDevice4);


            Console.ReadLine();
        }
Beispiel #2
0
 public bool PlugDevice(ConsumptionDevice nextDevice)
 {
     if (this.NextConnectedDevice != null || this.AvailablePower < nextDevice.ConsumptionPower)
     {
         return(false);
     }
     this.NextConnectedDevice           = nextDevice;
     nextDevice.PreviousConnectedDevice = this;
     return(true);
 }