public TurnOnCommand(Fan fan) { this.fan = fan; }
static void Main(string[] args) { Light light = new Light(); Fan fan = new Fan(); Thermostat thermostat = new Thermostat(); Remote remote = new Remote(); remote.SetButton(1, new TurnLightOn(light)); remote.SetButton(2, new TurnLightOff(light)); remote.SetButton(3, new TurnFanOn(fan)); remote.SetButton(4, new TurnFanOff(fan)); remote.SetButton(5, new TurnThermostatOn(thermostat)); remote.SetButton(6, new TurnThermostatOff(thermostat)); remote.SetButton(7, new TurnThermostatUp(thermostat)); remote.SetButton(8, new TurnThermostatDown(thermostat)); remote.SetButton(9, new TurnLightOff(light)); remote.SetButton(9, new TurnFanOff(fan)); remote.SetButton(9, new TurnThermostatOff(thermostat)); // Console.WriteLine($"Light is turned {light}"); // Console.WriteLine($"Fan is turned {fan}"); // Console.WriteLine($"Thermostat is turned {thermostat}"); // Console.WriteLine(); // // remote.PressButton(1); // remote.PressButton(3); // remote.PressButton(5); // // Console.WriteLine($"Light is turned {light}"); // Console.WriteLine($"Fan is turned {fan}"); // Console.WriteLine($"Thermostat is turned {thermostat}"); // Console.WriteLine(); // // for (int i = 0; i < 21; i++) // { // remote.PressButton(7); // } // Console.WriteLine($"Thermostat is turned {thermostat}"); // Console.WriteLine(); // // remote.PressButton(9); // // Console.WriteLine($"Light is turned {light}"); // Console.WriteLine($"Fan is turned {fan}"); // Console.WriteLine($"Thermostat is turned {thermostat}"); // Console.WriteLine(); string value; int input; bool cancel = false; //ShowStatus(light, fan, thermostat); while (!cancel) { Console.Clear(); ShowStatus(light, fan, thermostat); ShowOptions(); value = Console.ReadLine(); if (Int32.TryParse(value, out input)) { input = Convert.ToInt32(value); } else { input = 987; } switch (input) { case 1: remote.PressButton(1); ShowStatus(light, fan, thermostat); break; case 2: remote.PressButton(2); ShowStatus(light, fan, thermostat); break; case 3: remote.PressButton(3); ShowStatus(light, fan, thermostat); break; case 4: remote.PressButton(4); ShowStatus(light, fan, thermostat); break; case 5: remote.PressButton(5); ShowStatus(light, fan, thermostat); break; case 6: remote.PressButton(6); ShowStatus(light, fan, thermostat); break; case 7: remote.PressButton(7); ShowStatus(light, fan, thermostat); break; case 8: remote.PressButton(8); ShowStatus(light, fan, thermostat); break; case 9: remote.PressButton(9); ShowStatus(light, fan, thermostat); break; case 10: remote.Undo(); ShowStatus(light, fan, thermostat); break; case 11: cancel = true; break; case 987: ShowError(); break; default: ShowError(); break; } } }
public FanOnCommand(Fan fan) { _fan = fan; }
public FanOffCommand(Fan Fan) { _fan = Fan; }