Esempio n. 1
0
        static void Main(string[] args)
        {
            PipeSection obj1 = new PipeSection(5, 10, "участок №1");
            PipeSection obj2 = new PipeSection(17, 22, "участок №2");
            PipeSection obj3 = new PipeSection(22, 30, "участок №3");
            PipeSection obj4 = new PipeSection(0, 5, "участок №4");
            PipeSection obj5 = new PipeSection(11, 15, "участок №5");
            PipeSection obj6 = new PipeSection(31, 35, "участок №6");
            PipeSection obj7 = new PipeSection(35, 40, "участок №7");
            PipeSection obj8 = new PipeSection(39, 45, "участок №8");//не валидный
            Pipe        pipe = new Pipe();

            pipe.AddPipeSection(obj1);
            pipe.AddPipeSection(obj2);
            pipe.AddPipeSection(obj3);
            pipe.AddPipeSection(obj4);
            pipe.AddPipeSection(obj5);
            pipe.AddPipeSection(obj6);
            pipe.AddPipeSection(obj7);
            pipe.AddPipeSection(obj8);
            Console.WriteLine("Труба до обработки:");
            pipe.Print();
            Console.ReadKey();
            ProcessingPipe proc = new ProcessingPipe();

            proc.GetSetPipe = pipe;
            pipe            = proc.Processing();
            Console.WriteLine("Труба после обработки");
            pipe.Print();
            Console.ReadKey();
        }
Esempio n. 2
0
        public int CompareTo(object obj)
        {
            PipeSection pipesection = obj as PipeSection;

            if ((pipesection != null))
            {
                return(GetSetPipeSectionBegin.CompareTo(pipesection.GetSetPipeSectionBegin));
            }
            else
            {
                return(GetSetPipeSectionBegin.CompareTo(0));
            }
        }
Esempio n. 3
0
        private Pipe Connection(Pipe newPipe, Pipe obj)//объединение участков имеющих общие границы
        {
            PipeSection temp    = new PipeSection();
            int         counter = obj.GetPipe.Count();

            for (int i = 0; i < counter; i++)
            {
                temp = obj.GetPipe.Last();
                obj.GetPipe.Remove(temp);
                if (temp.GetSetPipeSectionBegin == obj.GetPipe.Last().GetSetPipeSectionEnd)
                {
                    PipeSection newPipeSection = new PipeSection(obj.GetPipe.Last().GetSetPipeSectionBegin,
                                                                 temp.GetSetPipeSectionEnd, obj.GetPipe.Last().GetSetPipeSectionName);
                    obj.GetPipe.RemoveAt(obj.GetPipe.Count - 1);
                    newPipe.GetPipe.Add(newPipeSection);
                    counter--;
                }
                else
                {
                    newPipe.GetPipe.Add(temp);
                }
            }
            return(newPipe);
        }
Esempio n. 4
0
 public void Add(PipeSection obj)
 {
     GetPipe.Add(obj);
 }