Esempio n. 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int    value  = 0;
            int    value2 = 0;
            string inform = "";

            if (numericUpDown2.Value != 0 && textBox2.Text != null && numericUpDown3.Value != 0)
            {
                value  = (int)numericUpDown2.Value;
                value2 = (int)numericUpDown3.Value;
                inform = textBox2.Text;
                IProduct new_product = new Dairy_products(inform, value, value2);



                if (new_product is Dairy_products)//сравнение типов
                {
                    array        = new IProduct[5];
                    product1     = new Dairy_products("молоко", 100, 50);
                    product2     = new Dairy_products("сыр", 20, 450);
                    product3     = new Dairy_products("ряженка", 50, 45);
                    product4     = new Dairy_products("сметана", 30, 65);
                    array[0]     = product1;
                    array[1]     = product2;
                    array[2]     = product3;
                    array[3]     = product4;
                    array[4]     = new_product;
                    label1.Text += "\n";
                    for (int i = 0; i < array.Length; i++)
                    {
                        label1.Text += "\n" + array[i].Show();
                    }
                }
            }
        }
Esempio n. 2
0
 public Form1()
 {
     InitializeComponent();
     array    = new IProduct[4];
     product1 = new Dairy_products("молоко", 100, 50);
     product2 = new Dairy_products("сыр", 20, 450);
     product3 = new Dairy_products("ряженка", 50, 45);
     product4 = new Dairy_products("сметана", 30, 65);
     array[0] = product1;
     array[1] = product2;
     array[2] = product3;
     array[3] = product4;
 }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            int value = 0;

            // string inform = "";
            if (numericUpDown1.Value != 0 && textBox1.Text != null)
            {
                value = (int)numericUpDown1.Value;
                // inform = textBox1.Text;

                for (int i = 0; i < array.Length; i++)
                {
                    Dairy_products new_product = array[i] as Dairy_products; //приведение к типу

                    if (textBox1.Text == new_product.Name)
                    {
                        label1.Text += "\n\n Наименование " + new_product.Name + "\nОстаток товара " + new_product.remains(value) + "\n Выручка с продажи товара " + new_product.revenue_new(value);
                    }
                }
            }
        }