Example #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;

                   }

               }
        }
Example #2
0
        static void Lamp(List <Technique.Lamp> Lamps)
        {
            string BaseColor = "White";
            string BaseName  = "Lamp1";
            bool   ToMenu    = false;



            while (!ToMenu)
            {
                Console.Clear();
                foreach (var l in Lamps)
                {
                    Console.WriteLine("Название:    " + l.Name + ", " + l.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 Lamp");
                    name = Console.ReadLine();

                    for (int lam = 0; lam < Lamps.Count; lam++)
                    {
                        if (Lamps[lam].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.Lamp lampp = new Technique.Lamp(name, false, BaseColor, 50);
                        Lamps.Add(lampp);
                    }
                }


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



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


                        switch (commands)
                        {
                        case "ON":
                            Lamps[lam].ON();
                            break;

                        case "OFF":
                            Lamps[lam].OFF();
                            break;

                        case "BR":
                            Lamps[lam].Brightness();
                            break;

                        case "CL":
                            Lamps[lam].ColorLoght();
                            break;

                        case "del":
                            Lamps.RemoveAt(lam);
                            break;

                        default:
                            Lamps[0].Help();
                            break;
                        }
                    }
                }
            }
        }
Example #3
0
        static void Lamp(List<Technique.Lamp>  Lamps)
        {
            string BaseColor = "White";
            string BaseName = "Lamp1";
            bool ToMenu = false;

            while (!ToMenu)
            {

                Console.Clear();
                foreach (var l in Lamps)
                {
                    Console.WriteLine("Название:    " + l.Name + ", " + l.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 Lamp");
                       name = Console.ReadLine();

                       for (int lam = 0; lam < Lamps.Count; lam++)
                       {
                           if (Lamps[lam].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.Lamp lampp = new Technique.Lamp(name, false, BaseColor, 50);
                           Lamps.Add(lampp);
                       }

                   }

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

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

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

                          switch (commands)
                          {
                              case "ON":
                                  Lamps[lam].ON();
                                  break;
                              case "OFF":
                                  Lamps[lam].OFF();
                                  break;
                              case "BR":
                                  Lamps[lam].Brightness();
                                  break;
                              case "CL":
                                  Lamps[lam].ColorLoght();
                                  break;
                              case "del":
                                  Lamps.RemoveAt(lam);
                                  break;

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

                      }

                  }
            }
        }
Example #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;
                }
            }
        }