Ejemplo n.º 1
0
        /// <summary>
        /// Adds the WaterPackets and returns them as the most advanced type.
        /// </summary>
        /// <param name="Waters"></param>
        /// <returns></returns>
        public static IWaterPacket Mix(IEnumerable <IWaterPacket> Waters)
        {
            if (Waters.Count() == 0)
            {
                return(null);
            }
            else if (Waters.Count() == 1)
            {
                return(Waters.First());
            }
            else
            {
                IWaterPacket[] warr   = Waters.ToArray();
                IWaterPacket   Water1 = warr[0];

                for (int i = 1; i < warr.Count(); i++)
                {
                    if (warr[i].GetType().IsSubclassOf(Water1.GetType()))
                    {
                        warr[i].Add(Water1);
                        Water1 = warr[i];
                    }
                    else
                    {
                        Water1.Add(warr[i]);
                    }
                }

                return(Water1);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds water
 /// </summary>
 /// <param name="W"></param>
 public override void Add(IWaterPacket W)
 {
   base.Add(W);
   //If we have chemicals add them
   if (W.GetType().Equals(this.GetType()))
   {
     foreach (KeyValuePair<Chemical, double> KVP in ((WaterWithChemicals)W)._chemicals)
     {
       if (_chemicals.ContainsKey(KVP.Key))
         _chemicals[KVP.Key] += KVP.Value;
       else
         _chemicals.Add(KVP.Key, KVP.Value);
     }
   }
   else
   {
     //Keep track of how much non-chemical water is added.
     _volumeOfNonChemicalWater += W.Volume;
   }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds water
 /// </summary>
 /// <param name="W"></param>
 public override void Add(IWaterPacket W)
 {
     base.Add(W);
     //If we have chemicals add them
     if (W.GetType().Equals(this.GetType()))
     {
         foreach (KeyValuePair <Chemical, double> KVP in ((WaterWithChemicals)W)._chemicals)
         {
             if (_chemicals.ContainsKey(KVP.Key))
             {
                 _chemicals[KVP.Key] += KVP.Value;
             }
             else
             {
                 _chemicals.Add(KVP.Key, KVP.Value);
             }
         }
     }
     else
     {
         //Keep track of how much non-chemical water is added.
         _volumeOfNonChemicalWater += W.Volume;
     }
 }