Example #1
0
 static void Main(string[] args)
 {
     ClassHome[] cl1;
     cl1 = ClassHome.BuildArrayMethod(); // Создаем массив
     cl1 = ClassHome.SortArray(cl1);     // Сортируем
     ClassHome.PrintMetod(cl1);          // Выводим
 }
Example #2
0
        public static ClassHome[] SortArray(ClassHome[] array)  //Метод сортировки
        {
            for (int i = 0; i < array.Length; i++)
            {
                for (int j = i + 1; j < array.Length; j++)
                {
                    if (array[i].etagnost < array[j].etagnost)
                    {
                        ClassHome b = new ClassHome();
                        b = array[i];

                        array[i] = array[j];
                        array[j] = b;
                    }
                }
            }
            return(array);
        }
Example #3
0
        public static ClassHome[] BuildArrayMethod()
        {
            int    arraySize;
            string input;

            do
            {
                Console.WriteLine("Введите количество домов (int)");   // Проверка вводимых данных о количестве
                input = Console.ReadLine();                            //домов на корректность
            } while (false == (Int32.TryParse(input, out arraySize))); //

            ClassHome[] arrayHomes = new ClassHome[arraySize];
            string      adress = "", kolEtageiS = "", kolPodezdovS = "", kolKvartirS = "";
            int         kolEtagei = 0, kolPodezdov = 0, kolKvartir = 0;

            for (int i = 0; i < arraySize; i++)
            {
notCorrect:
                Console.WriteLine("Введите адрес дома {0} из {1} домов ", i + 1, arraySize);
                adress = Console.ReadLine();
                Console.WriteLine("Этажность дома (int)");
                kolEtageiS = Console.ReadLine();
                Console.WriteLine("Количество подъездов(int)");
                kolPodezdovS = Console.ReadLine();
                Console.WriteLine("Количество квартир на этаже (int)");
                kolKvartirS = Console.ReadLine();
                if ((Int32.TryParse(kolEtageiS, out kolEtagei)) & (Int32.TryParse(kolPodezdovS, out kolPodezdov)) & (Int32.TryParse(kolKvartirS, out kolKvartir)))
                {
                    ClassHome home = new ClassHome(adress, kolEtagei, kolPodezdov, kolKvartir);
                    arrayHomes[i] = home;
                }
                else
                {
                    Console.WriteLine("Не корректный ввод данных, попробуйте снова");
                    goto notCorrect;
                }
            }
            return(arrayHomes);
        }