Пример #1
0
        public SubstanceMixture SubtractPart(float part)
        {
            if (part > 1 || part <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(part), "Must be inside (0, 1]");
            }


            SubstanceMixture mixture = new SubstanceMixture(_listImplementation.Count);

            for (int i = 0; i < _listImplementation.Count; i++)
            {
                SubstanceInfo info       = _listImplementation[i];
                SubstanceInfo subtracted = info;
                subtracted.Volume *= part;
                info.Volume       -= subtracted.Volume;
                mixture.Add(subtracted);
                _listImplementation[i] = info;
            }

            return(mixture);
        }
Пример #2
0
        public SubstanceMixture SubtractVolume(float volume)
        {
            if (volume > Volume)
            {
                throw new ArgumentOutOfRangeException(nameof(volume), "Must be inside (0, Volume of this instance]. Current volume: " + Volume);
            }

            SubstanceMixture mixture = new SubstanceMixture(_listImplementation.Count);

            float volumeTmp = Volume;

            for (int i = 0; i < _listImplementation.Count; i++)
            {
                SubstanceInfo info       = _listImplementation[i];
                SubstanceInfo subtracted = info;
                subtracted.Volume      = volume * info.Volume / volumeTmp;
                info.Volume           -= subtracted.Volume;
                _listImplementation[i] = info;

                mixture.Add(subtracted);
            }

            return(mixture);
        }