示例#1
0
        static void Main(string[] args)
        {
            MyListInt myListInt = new MyListInt();

            string[] itemsMenu = { "Добавить элемент",                         "Удалить элемент",                          "Показать",
                                   "Найти сумму всех положительных элементов", "Найти сумму всех отрицательных элементов", "Выход" };
            bool     end = false;

            do
            {
                int choice = ConsoleMenu.Show(itemsMenu);

                switch (choice)
                {
                case 0: AddItem(myListInt); break;

                case 1: RemoveItem(myListInt); break;

                case 2: ShowItems(myListInt); break;

                case 3: SumAllPlus(myListInt); break;

                case 4: SumAllMinus(myListInt); break;

                case 5: end = true; break;
                }
            } while (!end);
        }
示例#2
0
 static void SumAllMinus(MyListInt myList)
 {
     if (myList.Count == 0)
     {
         Console.WriteLine("Массив пуст");
         Console.ReadKey();
         return;
     }
     Console.WriteLine("Сумма всех отрицательных элементов массива");
     Console.WriteLine(myList.SumAllMinus());
     Console.ReadKey();
 }
示例#3
0
        static void RemoveItem(MyListInt myList)
        {
            if (myList.Count == 0)
            {
                Console.WriteLine("Массив пуст");
                Console.ReadKey();
                return;
            }

            int choice = ConsoleMenu.Show(myList.Show());

            myList.RemoveAt(choice);
        }
示例#4
0
        static void ShowItems(MyListInt myList)
        {
            if (myList.Count == 0)
            {
                Console.WriteLine("Массив пуст");
                Console.ReadKey();
                return;
            }

            for (int i = 0; i < myList.Count; i++)
            {
                Console.WriteLine($"{i+1}. " + myList[i]);
            }
            Console.ReadKey();
        }
示例#5
0
 static void AddItem(MyListInt myList)
 {
     Console.WriteLine("Введите число, которое необходимо добавить");
     myList.Add(UpgradedConsole.GetInt());
 }