コード例 #1
0
ファイル: TaskG.cs プロジェクト: xholik1/70-483
        public void Check()
        {
            var currentTemperature   = _currentTemperatureProvider.GetTemperature();
            var requestedTemperature = _temperatureSettingsProvider.GetRequestedTemperature();

            if (currentTemperature > requestedTemperature && _heater.IsStarted)
            {
                _heater.Stop();
            }

            if (currentTemperature < requestedTemperature && !_heater.IsStarted)
            {
                _heater.Start();
            }
        }
コード例 #2
0
        public void HeatUpTo(int threshold)
        {
            if (!_sensor.IsWaterPresent)
            {
                throw new NoWaterException("There is no water in the Kettle");
            }

            while (_sensor.Temperature < threshold)
            {
                _heater.Start();
                Console.WriteLine($"Heating water; current temperature {_sensor.Temperature}");
                Thread.Sleep(100);
                _sensor.Temperature++;
            }
            _heater.Stop();
        }