public void CreateDevice(Dictionary<string, Device> obj, string choice) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Меню создания компонента Умного дома".ToUpper() + "\n"); Console.ResetColor(); Console.WriteLine("Введите имя устройства"); string name = Console.ReadLine(); if (choice == "лампа") { Lamp myLamp = new Lamp(); myLamp.DeviceName = name; obj.Add(name, myLamp); Console.Clear(); Console.WriteLine("Компонент успешно создан \n".ToUpper()); Console.WriteLine(myLamp.ToString()); Console.ReadKey(); } if (choice == "кондиционер") { Conditioner myConditioner = new Conditioner(); myConditioner.DeviceName = name; SubMenuToCreateClimatobject(myConditioner); obj.Add(name, myConditioner); Console.Clear(); Console.WriteLine("Компонент успешно создан \n".ToUpper()); Console.WriteLine(myConditioner.ToString()); Console.ReadKey(); } if (choice == "котел") { HeatingBoiler myBoiler = new HeatingBoiler(); myBoiler.DeviceName = name; SubMenuToCreateClimatobject(myBoiler); obj.Add(name, myBoiler); Console.WriteLine("Компонент успешно создан \n".ToUpper()); Console.WriteLine(myBoiler.ToString()); Console.ReadKey(); } if (choice == "кухонная вытяжка") { KitchenVentilation myVentilation = new KitchenVentilation(); myVentilation.DeviceName = name; obj.Add(name, myVentilation); Console.Clear(); Console.WriteLine("Компонент успешно создан \n".ToUpper()); Console.WriteLine(myVentilation.ToString()); Console.ReadKey(); } if (choice == "плита") { Burner B1 = new Burner(); Burner B2 = new Burner(); Burner B3 = new Burner(); Burner B4 = new Burner(); CookingSurfase CS1 = new CookingSurfase("CS1", false, B1, B2, B3, B4); Oven O = new Oven(); Stove myCooker = new Stove(CS1, O); myCooker.DeviceName = name; obj.Add(name, myCooker); Console.Clear(); Console.WriteLine("Компонент успешно создан \n".ToUpper()); Console.WriteLine(myCooker.ToString()); Console.ReadKey(); } }
public Stove(string deviceName, bool deviceState, CookingSurfase myCookingSurfase, Oven myOven) : base(deviceName, deviceState) { this.MyCookingSurfase = myCookingSurfase; this.MyOven = myOven; }
static void Main(string[] args) { Dictionary<string, Device> smartDevices = new Dictionary<string, Device>(); smartDevices.Add("L1", new Lamp("L1", false)); smartDevices.Add("C1", new Conditioner("C1", false, 40, 0, 0, EnumSeasons.summer)); Burner b1 = new Burner(); Burner b2 = new Burner(); Burner b3 = new Burner(); Burner b4 = new Burner(); CookingSurfase CookSurf = new CookingSurfase("CookSurf", false, b1, b2, b3, b4); Oven O1 = new Oven("Oven1", true, EnumOvenMode.bottomHeat, 0, true); smartDevices.Add("Cook1", new Stove("Cook1", false, CookSurf, O1)); smartDevices.Add("H1", new HeatingBoiler("H1", false, 40, 0, 0, EnumSeasons.summer)); smartDevices.Add("K1", new KitchenVentilation("K1", false, Mode.normal)); Menu menu = new Menu(); string command1; string command2; string[] C1; for (int count3 = 0; ; count3++) { menu.MainMenu(); command1 = Console.ReadLine(); Console.Clear(); C1 = command1.Split(' '); if (C1[0] == "выход") { Environment.Exit(0); } else { switch (C1[0]) { case "конфигурация": for (int count = 0; ; count++) { command2 = menu.MenuForKonfiguration(); string[] C2 = command2.Split(' '); if (C2[0] == "вернуться") { menu.MainMenu(); break; } else { switch (C2[0]) { case "создать": menu.CreateDevice(smartDevices, C2[3]); Console.Clear(); menu.DisplayObjectsAll(smartDevices); Console.ReadKey(); break; case "удалить": Console.Clear(); menu.DisplayObjectNames(smartDevices); menu.MenuToDeleteComponent(smartDevices); menu.DisplayObjectsAll(smartDevices); Console.ReadKey(); break; } } } break; case "управление": try { menu.MenuToManageComponent(smartDevices); } catch (OverflowException e) { Console.WriteLine("ОШИБКА: " + e.Message); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine("ОШИБКА: " + ex.Message); Console.ReadKey(); } break; case "отображение": menu.MenuToDisplayObjects(smartDevices); break; } } } }
public Stove(CookingSurfase cs, Oven o) { this.myCookingSurfase = cs; this.MyOven = o; }