Ejemplo n.º 1
0
 public shop(int kol, double profit, int sale_count, shoes para)
 {
     this.kol        = kol;
     this.profit     = profit;
     this.sale_count = sale_count;
     this.para[0]    = para;
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            double sum = 0;
            int    tax = 0;

            //Двумерный массив объектов
            shoes[,] p = new shoes[10, 10];
            int box   = 0;
            int k_box = 0;

            Console.WriteLine("Введите количество коробок на складе");
            box = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Введите количество пар в коробке");
            k_box = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < box; i++)
            {
                for (int j = 0; j < k_box; j++)
                {
                    p[i, j] = new shoes();
                    p[i, j].read();
                }
            }
            shop sklad = new shop(box, k_box, p);

            sklad.display_sklad();

            // Одномерный массив объектов
            Console.WriteLine("Введите количество пар в коробке");
            k_box = Convert.ToInt32(Console.ReadLine());
            shoes[] p1 = new shoes [10];
            for (int i = 0; i < k_box; i++)
            {
                p1[i] = new shoes();
                p1[i].read();
            }
            shop boxx = new shop(k_box, p1);

            boxx.display_box();
            //Массив через конструтор с одним параметром
            shoes[] s = new shoes [2];
            Console.WriteLine("Инициализация массива через коутркутор с 1 параметром");
            for (int i = 0; i < 2; i++)
            {
                s[i] = new shoes(i);
                s[i].display();
            }
            Console.WriteLine("Работа со статическими объектами");

            // Конструктор без параметров
            shoes pr1 = new shoes();

            pr1.read();

            // Конструктор со всеми параметрами
            shop sh1 = new shop(1, 0, 0, pr1);

            sh1.display();

            // Статический метод
            shop.nalog(ref tax);
            Console.WriteLine("Налог на обувь: {0}\n", tax);

            Console.WriteLine("\nПосле продажи: \n");
            sh1.sale();

            Console.WriteLine("Общая стоимость товаров: {0}\n", sum);
            sum = pr1.add(sum);
            sh1.display();
            Console.WriteLine("Общая стоимость товаров: {0}\n", sum);
            Console.WriteLine("\nПосле возврата: \n");
            sh1.back();
            sum = pr1.add(sum);
            sh1.display();
            Console.WriteLine("Перегрузки:\n");
            shop sh10 = new shop(1, 0, 3, pr1);

            sh10 = ++sh1;
            Console.WriteLine("Перефикс {0}:", sh10.Sale_count);
            sh10.Sale_count = 3;
            sh1.Sale_count  = 0;
            sh10            = sh1++;
            Console.WriteLine("Постфикс {0}:", sh10.Sale_count);
            Console.WriteLine("Общая стоимость товаров: {0}\n", sum);
            tax = 0;
            Console.WriteLine("\nРабота с динамическими объектами\n");
            Console.WriteLine("Введите количество позиций:\n");
            sum = 0;
            int k = Int32.Parse(Console.ReadLine());

            shoes[] pr2 = new shoes[k];
            for (int i = 0; i < k; i++)
            {
                pr2[i] = new shoes();
                pr2[i].read();
                sum = pr2[i].add(sum);
                // Статический метод
                shop.nalog(ref tax);
            }
            shop sh2 = new shop(k, 0, 0, pr2);

            sh2.display();
            Console.WriteLine("Налог на обувь: {0}\n", tax);
            Console.WriteLine("Общая стоимость товаров: {0}\n", sum);
            Console.WriteLine("\nПосле продажи: \n");
            sh2.sale();
            sum = pr2[sh2.Kol].return_sum(sum);
            sh2.display();
            Console.WriteLine("Общая стоимость товаров: {0}\n", sum);
            Console.WriteLine("\nПосле возврата: \n");
            sh2.back();
            sum = pr2[sh2.Kol - 1].add(sum);
            sh2.display();
        }