Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Misto prep1 = new Misto("Lviv", 182, 7000000);
            Misto prep2 = new Misto("Uzhgorod", 40, 12321332);
            Misto prep3 = new Misto("Rivne", 63, 123332);
            Misto prep4 = new Misto("Kyiv", 847, 1000000);
            Misto prep5 = new Misto("Odesa", 162, 600000);
            Misto prep6 = new Misto("Harkiv", 350, 70000);

            Misto[] group = new Misto[6];
            group[0] = prep1;
            group[1] = prep2;
            group[2] = prep3;
            group[3] = prep4;
            group[4] = prep5;
            group[5] = prep6;
            Console.WriteLine("sort is width:");
            Array.Sort(group, new Misto.SortByWidht());
            foreach (Misto elem in group)
            {
                elem.Passport();
            }
            Console.WriteLine("sort is naselenya:");
            Array.Sort(group, new Misto.SortByNaselenya());
            foreach (Misto elem in group)
            {
                elem.Passport();
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
            int IComparer.Compare(object ob1, object ob2)
            {
                Misto p1 = (Misto)ob1;
                Misto p2 = (Misto)ob2;

                if (p1.Widht > p2.Widht)
                {
                    return(1);
                }
                if (p1.Widht < p2.Widht)
                {
                    return(-1);
                }
                return(0);
            }
Ejemplo n.º 3
0
            int IComparer.Compare(object ob1, object ob2)
            {
                Misto p1 = (Misto)ob1;
                Misto p2 = (Misto)ob2;

                if (p1.Naselenya > p2.Naselenya)
                {
                    return(1);
                }
                if (p1.Naselenya < p2.Naselenya)
                {
                    return(-1);
                }
                return(0);
            }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Misto prep1  = new Misto("Lviv", 182, 7000000);
            Misto prep2  = new Misto("Uzhgorod", 40, 12321332);
            Misto prep3  = new Misto("Rivne", 63, 123332);
            Misto prep4  = new Misto("Kyiv", 847, 1000000);
            Misto prep5  = new Misto("Odesa", 162, 600000);
            Misto prep6  = new Misto("Harkiv", 350, 70000);
            Misto prep7  = new Misto("Zytomer", 30, 1123);
            Misto prep8  = new Misto("Stryy", 15, 1);
            Misto prep9  = new Misto("Mukachevo", 24, 12132);
            Misto prep10 = new Misto("Krym", 45, 32323);

            Misto[] group = new Misto[10];
            group[0] = prep1;
            group[1] = prep2;
            group[2] = prep3;
            group[3] = prep4;
            group[4] = prep5;
            group[5] = prep6;
            group[6] = prep7;
            group[7] = prep8;
            group[8] = prep9;
            group[9] = prep10;
            Console.WriteLine("sort is width:");
            Array.Sort(group, new Misto.SortByWidht());
            foreach (Misto elem in group)
            {
                elem.Passport();
            }
            Console.WriteLine("sort is naselenya:");
            Array.Sort(group, new Misto.SortByNaselenya());
            foreach (Misto elem in group)
            {
                elem.Passport();
            }
            Console.ReadLine();
        }