コード例 #1
0
    static void Main(string[] args)
    {
        Thermostat thermostat = new Thermostat();

        Heater heater = new Heater(30);

        Cooler cooler = new Cooler(40);

        thermostat.EmulateTemperatureChange();

        heater.OnTemperatureChanged(thermostat.CurrentTemperature);

        cooler.Update(thermostat.CurrentTemperature);

        thermostat.EmulateTemperatureChange();

        heater.OnTemperatureChanged(thermostat.CurrentTemperature);

        cooler.Update(thermostat.CurrentTemperature);
    }
コード例 #2
0
        private void AddOrUpdateColumn(string addOrUpdate)
        {
            c.Id           = int.Parse(textBoxCoolerId.Text);
            c.Manufacturer = textBoxCoolerManufacturer.Text;
            c.Name         = textBoxCoolerName.Text;
            c.FanRPM       = int.Parse(textBoxCoolerFanRpm.Text);
            c.NoiseLevelDb = int.Parse(textBoxCoolerNoiseLevel.Text);
            c.Price        = double.Parse(textBoxCoolerPrice.Text);

            bool success = addOrUpdate == "added" ? c.Insert(c) : c.Update(c);

            helperMethods.DisplayMessage(success, addOrUpdate, this, c, componentName, coolerBrowseGV);
        }