예제 #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 Conditioner(List <Technique.Conditioner> Conditioners)
        {
            bool ToMenu = false;



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

                    for (int cond = 0; cond < Conditioners.Count; cond++)
                    {
                        if (Conditioners[cond].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.Conditioner conditioner = new Technique.Conditioner(name, false, 2);
                        Conditioners.Add(conditioner);
                    }
                }


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



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


                        switch (commands)
                        {
                        case "ON":
                            Conditioners[cond].ON();
                            break;

                        case "OFF":
                            Conditioners[cond].OFF();
                            break;

                        case "H":
                            Conditioners[cond].Hot();
                            break;

                        case "S":
                            Conditioners[cond].Odinary();
                            break;

                        case "C":
                            Conditioners[cond].Cold();
                            break;



                        case "del":
                            Conditioners.RemoveAt(cond);
                            break;

                        default:
                            Conditioners[0].Help();
                            break;
                        }
                    }
                }
            }
        }
예제 #3
0
        static void Conditioner(List<Technique.Conditioner> Conditioners)
        {
            bool ToMenu = false;

            while (!ToMenu)
            {

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

                    for (int cond = 0; cond < Conditioners.Count; cond++)
                    {
                        if (Conditioners[cond].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.Conditioner conditioner = new Technique.Conditioner(name,false,2);
                        Conditioners.Add(conditioner);
                    }

                }

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

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

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

                        switch (commands)
                        {
                            case "ON":
                                Conditioners[cond].ON();
                                break;

                            case "OFF":
                                Conditioners[cond].OFF();
                                break;

                            case "H":
                                Conditioners[cond].Hot();
                                break;

                            case "S":
                                Conditioners[cond].Odinary();
                                break;

                            case "C":
                                Conditioners[cond].Cold();
                                break;

                            case "del":
                                Conditioners.RemoveAt(cond);
                                break;

                            default:
                                Conditioners[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;
                }
            }
        }