Пример #1
0
        static void Main(string[] args)
        {
            string BaseColor="White";
            string BaseName1 = "Lamp1";
            string BaseName2 = "Kettle1";
            string BaseName3 = "TV1";
            string BaseName4 = "Clock1";
            string BaseName5 = "Fridge1";
            string BaseName6 = "Conditioner1";

            bool IsExite=false;

              List<Technique.Lamp> Lamps;
              List<Technique.Kettle> Kettles;
              List<Technique.TeleVision> TVs;
              List<Technique.Clock> Clocks;
              List<Technique.Fridge> Fridges;
              List<Technique.Conditioner> Conditioners;

             // Создание 1го элемента типа лампа Lamp
              Lamps = new List<Technique.Lamp>();
              Technique.Lamp lamp = new Technique.Lamp(BaseName1,false,BaseColor,50);
              Lamps.Add(lamp);
              // Создание 1го элемента типа чайник Kettle
               Kettles = new List<Technique.Kettle>();
               Technique.Kettle kettle = new Technique.Kettle(BaseName2, false, BaseColor);
               Kettles.Add(kettle);
               // Создание 1го элемента типа чайник TeleVision
               TVs = new List<Technique.TeleVision>();
               Technique.TeleVision tv = new Technique.TeleVision(BaseName3, false);
               TVs.Add(tv);
               // Создание 1го элемента типа чайник Clock
               Clocks = new List<Technique.Clock>();
               Technique.Clock cl = new Technique.Clock(BaseName4, false);
               Clocks.Add(cl);
               // Создание 1го элемента типа чайник Fridge
               Fridges = new List<Technique.Fridge>();
               Technique.Fridge fr = new Technique.Fridge(BaseName5, false,false,1);
               Fridges.Add(fr);
               // Создание 1го элемента типа чайник Conditioner
               Conditioners = new List<Technique.Conditioner>();
               Technique.Conditioner con = new Technique.Conditioner(BaseName6,false,2);
               Conditioners.Add(con);

               while (!IsExite)
               {
                   Console.Clear();
                   foreach (var l in Lamps)
                   {
                       Console.WriteLine("Название:    " + l.Name + ", " + l.ToString());
                   }
                   foreach (var k in Kettles)
                   {
                       Console.WriteLine("Название:    " + k.Name + ", " + k.ToString());
                   }
                   foreach (var t in TVs)
                   {
                       Console.WriteLine("Название:    " + t.Name + ", " + t.ToString());
                   }
                   foreach (var c in Clocks)
                   {
                       Console.WriteLine("Название:    " + c.Name + ", " + c.ToString());
                   }
                   foreach (var fridge in Fridges)
                   {
                       Console.WriteLine("Название:    " + fridge.Name + ", " + fridge.ToString());
                   }
                   foreach (var cond in Conditioners)
                   {
                       Console.WriteLine("Название:    " + cond.Name + ", " +cond.ToString());
                   }
                   Console.WriteLine();

                   string Search_Name;
                   Console.WriteLine("Enter the Type of the device whot parametr you whont to change");
                   Search_Name = Console.ReadLine();
                   Console.WriteLine();

                   switch (Search_Name)
                   {
                       case "exit":
                           IsExite = true;
                           break;

                       case "Lamp":
                           Lamp(Lamps);
                           break;

                       case "Kettle":
                           Kettle(Kettles);
                           break;

                       case "TV":
                           TV(TVs);
                           break;

                       case "Clock":
                           Clock(Clocks);
                           break;

                       case "Fridge":
                           Fridge(Fridges);
                           break;

                       case "Con":
                           Conditioner(Conditioners);
                           break;

                       default:
                           Help();
                           break;

                   }

               }
        }
Пример #2
0
        static void Clock(List <Technique.Clock> Clocks)
        {
            bool ToMenu = false;



            while (!ToMenu)
            {
                Console.Clear();
                foreach (var cl in Clocks)
                {
                    Console.WriteLine("Название:    " + cl.Name + ", " + cl.ToString());
                }

                string Search_Name;
                Console.WriteLine("Enter name of the device");
                Search_Name = Console.ReadLine();
                Console.WriteLine();



                if (Search_Name == "add")
                {
                    string name;
                    bool   HasName = false;

                    Console.WriteLine("Enter name of the Alarm");
                    name = Console.ReadLine();

                    for (int clock = 0; clock < Clocks.Count; clock++)
                    {
                        if (Clocks[clock].Name != name)
                        {
                            HasName = true;
                        }
                        else
                        {
                            HasName = false;
                            Console.WriteLine("The device whith this name hes already");
                            Console.WriteLine("");
                            Console.WriteLine("Press any key for continue");
                            Console.ReadLine();
                        }
                    }
                    if (HasName == true)
                    {
                        HasName = false;
                        Technique.Clock clock = new Technique.Clock(name, false);
                        Clocks.Add(clock);
                    }
                }


                if (Search_Name == "beak")
                {
                    ToMenu = true;
                }



                for (int clock = 0; clock < Clocks.Count; clock++)
                {
                    if (Clocks[clock].Name == Search_Name)
                    {
                        Console.Write("Введите команду: ");
                        string commands = Console.ReadLine();


                        switch (commands)
                        {
                        case "ON":
                            Clocks[clock].ON();
                            break;

                        case "OFF":
                            Clocks[clock].OFF();
                            break;

                        case "CT":
                            Clocks[clock].ChangeTime();
                            break;

                        case "del":
                            Clocks.RemoveAt(clock);
                            break;

                        default:
                            Clocks[0].Help();
                            break;
                        }
                    }
                }
            }
        }
Пример #3
0
        static void Clock(List<Technique.Clock> Clocks)
        {
            bool ToMenu = false;

            while (!ToMenu)
            {

                Console.Clear();
                foreach (var cl in Clocks)
                {
                    Console.WriteLine("Название:    " + cl.Name + ", " + cl.ToString());
                }

                string Search_Name;
                Console.WriteLine("Enter name of the device");
                Search_Name = Console.ReadLine();
                Console.WriteLine();

                if (Search_Name == "add")
                {
                    string name;
                    bool HasName = false;

                    Console.WriteLine("Enter name of the Alarm");
                    name = Console.ReadLine();

                    for (int clock = 0; clock < Clocks.Count; clock++)
                    {
                        if (Clocks[clock].Name != name)
                        {
                            HasName = true;
                        }
                        else
                        {
                            HasName = false;
                            Console.WriteLine("The device whith this name hes already");
                            Console.WriteLine("");
                            Console.WriteLine("Press any key for continue");
                            Console.ReadLine();
                        }

                    }
                    if (HasName == true)
                    {
                        HasName = false;
                        Technique.Clock clock = new Technique.Clock(name, false);
                        Clocks.Add(clock);
                    }

                }

                if (Search_Name == "beak")
                {
                    ToMenu = true;
                }

                for (int clock = 0; clock < Clocks.Count; clock++)
                {
                    if (Clocks[clock].Name == Search_Name)
                    {

                        Console.Write("Введите команду: ");
                        string commands = Console.ReadLine();

                        switch (commands)
                        {
                            case "ON":
                                Clocks[clock].ON();
                                break;

                            case "OFF":
                                Clocks[clock].OFF();
                                break;

                            case "CT":
                                Clocks[clock].ChangeTime();
                                break;

                            case "del":
                                Clocks.RemoveAt(clock);
                                break;

                            default:
                                Clocks[0].Help();
                                break;
                        }

                    }
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            string BaseColor = "White";
            string BaseName1 = "Lamp1";
            string BaseName2 = "Kettle1";
            string BaseName3 = "TV1";
            string BaseName4 = "Clock1";
            string BaseName5 = "Fridge1";
            string BaseName6 = "Conditioner1";

            bool IsExite = false;


            List <Technique.Lamp>        Lamps;
            List <Technique.Kettle>      Kettles;
            List <Technique.TeleVision>  TVs;
            List <Technique.Clock>       Clocks;
            List <Technique.Fridge>      Fridges;
            List <Technique.Conditioner> Conditioners;

            // Создание 1го элемента типа лампа Lamp
            Lamps = new List <Technique.Lamp>();
            Technique.Lamp lamp = new Technique.Lamp(BaseName1, false, BaseColor, 50);
            Lamps.Add(lamp);
            // Создание 1го элемента типа чайник Kettle
            Kettles = new List <Technique.Kettle>();
            Technique.Kettle kettle = new Technique.Kettle(BaseName2, false, BaseColor);
            Kettles.Add(kettle);
            // Создание 1го элемента типа чайник TeleVision
            TVs = new List <Technique.TeleVision>();
            Technique.TeleVision tv = new Technique.TeleVision(BaseName3, false);
            TVs.Add(tv);
            // Создание 1го элемента типа чайник Clock
            Clocks = new List <Technique.Clock>();
            Technique.Clock cl = new Technique.Clock(BaseName4, false);
            Clocks.Add(cl);
            // Создание 1го элемента типа чайник Fridge
            Fridges = new List <Technique.Fridge>();
            Technique.Fridge fr = new Technique.Fridge(BaseName5, false, false, 1);
            Fridges.Add(fr);
            // Создание 1го элемента типа чайник Conditioner
            Conditioners = new List <Technique.Conditioner>();
            Technique.Conditioner con = new Technique.Conditioner(BaseName6, false, 2);
            Conditioners.Add(con);



            while (!IsExite)
            {
                Console.Clear();
                foreach (var l in Lamps)
                {
                    Console.WriteLine("Название:    " + l.Name + ", " + l.ToString());
                }
                foreach (var k in Kettles)
                {
                    Console.WriteLine("Название:    " + k.Name + ", " + k.ToString());
                }
                foreach (var t in TVs)
                {
                    Console.WriteLine("Название:    " + t.Name + ", " + t.ToString());
                }
                foreach (var c in Clocks)
                {
                    Console.WriteLine("Название:    " + c.Name + ", " + c.ToString());
                }
                foreach (var fridge in Fridges)
                {
                    Console.WriteLine("Название:    " + fridge.Name + ", " + fridge.ToString());
                }
                foreach (var cond in Conditioners)
                {
                    Console.WriteLine("Название:    " + cond.Name + ", " + cond.ToString());
                }
                Console.WriteLine();



                string Search_Name;
                Console.WriteLine("Enter the Type of the device whot parametr you whont to change");
                Search_Name = Console.ReadLine();
                Console.WriteLine();


                switch (Search_Name)
                {
                case "exit":
                    IsExite = true;
                    break;

                case "Lamp":
                    Lamp(Lamps);
                    break;

                case "Kettle":
                    Kettle(Kettles);
                    break;

                case "TV":
                    TV(TVs);
                    break;

                case "Clock":
                    Clock(Clocks);
                    break;

                case "Fridge":
                    Fridge(Fridges);
                    break;

                case "Con":
                    Conditioner(Conditioners);
                    break;

                default:
                    Help();
                    break;
                }
            }
        }