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(); } }
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(); }