Пример #1
0
        public static void Actions(MyNewCollection collection)
        {
            collection.Print();
            Console.WriteLine("1- Выбрать товар");
            Console.WriteLine("2- Сортировка товара по цене");
            Console.WriteLine("3- Удалить товар");

            switch (Console.ReadLine())
            {
            case "1":
                Console.WriteLine("Введите индекс товара");
                try
                {
                    int     index   = InputValidator.InputPositive();
                    Product product = collection[index];
                    string  name    = Console.ReadLine();
                    string price
                    product.ChangeProduct();

                    collection.ChangeProduct(index, product);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Товара нет в списке");
                }

                Actions(collection);
                break;

            case "2":
                collection.SortByPrice();
                collection.Print();
                Actions(collection);
                break;

            case "3":
                try
                {
                    int     index   = InputValidator.InputPositive();
                    Product product = collection[index];
                    collection.Remove(product);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Товара нельзя удалить");
                }
                break;

            default:
                Actions(collection);
                break;
            }
        }