Пример #1
0
        public TemperatureConverter()
        {
            var kelvinScale    = new KelvinScale();
            var farenheitScale = new FarenheitScale();
            var celsiusScale   = new CelsiusScale();

            _scales.Add(kelvinScale);
            _scales.Add(farenheitScale);
            _scales.Add(celsiusScale);

            /*
             * Add your scale classes here like this:
             *
             * var scaleName = new ClassName();
             * scales.Add(scaleName);
             */
        }
Пример #2
0
        public TemperatureConverter()
        {
            var celsiusScale = new CelsiusScale();
            var kelvinScale  = new KelvinScale();

            scales.Add(celsiusScale);
            scales.Add(kelvinScale);

            foreach (var scale in scales)
            {
                foreach (var rule in scale.ConvertingRules)
                {
                    if (!convertingRules.ContainsKey(rule.Key))
                    {
                        convertingRules.Add(rule.Key, rule.Value);
                    }
                }
            }
        }