Esempio n. 1
0
    public void AddLiquid(LiquidsCollection newLiquidsCollection)
    {
        // If there's no room, don't add anything
        if (currentVolume >= maxVolume)
        {
            return;
        }

        // If the incoming liquid is the same as the top liquid, add to the volume of it
        double remainingVolume = maxVolume - currentVolume;

        if (LiquidsCollList[LiquidsCollList.Count - 1].SameLiquidMix(newLiquidsCollection))
        {
            LiquidsCollList[LiquidsCollList.Count - 1].Combine(newLiquidsCollection, remainingVolume);
        }

        // else the incoming liquid is different and will be added
        else
        {
            if (newLiquidsCollection.CombinedVolume > remainingVolume)
            {
                newLiquidsCollection.ResizeTotalVolume(remainingVolume);
            }
            LiquidsCollList.Add(newLiquidsCollection);
        }
    }
Esempio n. 2
0
        public void Combine(LiquidsCollection newLiquidsCollection, double remainingSpace)
        {
            if (newLiquidsCollection.CombinedVolume > remainingSpace)
            {
                ResizeTotalVolume(remainingSpace);
            }
            Dictionary <LiquidType, Liquid> newLiquidsDict = newLiquidsCollection.LiquidsDict;

            foreach (KeyValuePair <LiquidType, Liquid> entry in newLiquidsDict)
            {
                AddLiquid(entry.Value, remainingSpace);
                remainingSpace -= entry.Value.volume;
            }
        }
Esempio n. 3
0
 public bool SameLiquidMix(LiquidsCollection liquidsCollection)
 {
     return(SameLiquidMix(liquidsCollection.LiquidTypes));
 }