示例#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 Fridge(List <Technique.Fridge> Fridges)
        {
            bool ToMenu = false;



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

                    for (int fr = 0; fr < Fridges.Count; fr++)
                    {
                        if (Fridges[fr].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.Fridge fridge = new Technique.Fridge(name, false, false, 1);
                        Fridges.Add(fridge);
                    }
                }


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



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


                        switch (commands)
                        {
                        case "ON":
                            Fridges[fr].ON();
                            break;

                        case "OFF":
                            Fridges[fr].OFF();
                            break;

                        case "OnF":
                            Fridges[fr].ONFrize();
                            break;

                        case "OfF":
                            Fridges[fr].OFFFrize();
                            break;

                        case "PR":
                            Fridges[fr].Programm();
                            break;


                        case "del":
                            Fridges.RemoveAt(fr);
                            break;

                        default:
                            Fridges[0].Help();
                            break;
                        }
                    }
                }
            }
        }
示例#3
0
        static void Fridge(List<Technique.Fridge> Fridges)
        {
            bool ToMenu = false;

            while (!ToMenu)
            {

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

                    for (int fr = 0; fr < Fridges.Count; fr++)
                    {
                        if (Fridges[fr].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.Fridge fridge = new Technique.Fridge(name, false,false,1);
                        Fridges.Add(fridge);
                    }

                }

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

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

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

                        switch (commands)
                        {
                            case "ON":
                                Fridges[fr].ON();
                                break;

                            case "OFF":
                                Fridges[fr].OFF();
                                break;

                            case "OnF":
                                Fridges[fr].ONFrize();
                                break;

                            case "OfF":
                                Fridges[fr].OFFFrize();
                                break;

                            case "PR":
                                Fridges[fr].Programm();
                                break;

                            case "del":
                                Fridges.RemoveAt(fr);
                                break;

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