Exemple #1
0
        public static void CalculateMenu(MyArray array)
        {
            Console.Clear();
            int choice = 0;

            Console.Write("1 - Sum of negative elements\n2 - Sum of all elements\nYour choice: ");
            choice = int.Parse(Console.ReadLine());
            switch (choice)
            {
            case 1:
                Console.Clear();
                array.RegisterToChange(SumNegativeElements);
                array.Change();
                break;

            case 2:
                Console.Clear();
                array.RegisterToChange(SumAllElements);
                array.Change();
                break;

            default:
                break;
            }
        }
Exemple #2
0
        public static void ChangeMenu(MyArray array)
        {
            Console.Clear();
            int choice = 0;

            Console.Write("1 - Change all elements to 0\n2 - Sort array\nYour choice: ");
            choice = int.Parse(Console.ReadLine());
            switch (choice)
            {
            case 1:
                Console.Clear();
                array.RegisterToChange(NegativeToNull);
                array.Change();
                break;

            case 2:
                Console.Clear();
                array.RegisterToChange(SortArray);
                array.Change();
                break;

            default:
                break;
            }
        }
Exemple #3
0
        public static void Menu(MyArray array)
        {
            int  choice = 0;
            bool exit   = false;

            while (!exit)
            {
                Console.Clear();
                Console.Write("1 - Calculate array\n2 - Change array\n3 - Show array\n0 - Exit\nYour choice: ");
                choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    CalculateMenu(array);
                    Console.ReadLine();
                    break;

                case 2:
                    ChangeMenu(array);
                    Console.ReadLine();
                    break;

                case 3:
                    Console.Clear();
                    array.Show();
                    Console.ReadLine();
                    break;

                case 0:
                    exit = true;
                    break;

                default:
                    break;
                }
            }
        }
Exemple #4
0
 static void Main(string[] args)
 {
     arr = new MyArray(10);
     arr.Fill();
     Menu(arr);
 }