Exemple #1
0
        public static void Item_On_Price_Range(int min, int max, GYM gym)
        {
            int i = 0;

            while (gym[i + 1] != null)
            {
                if (gym[i].Price >= min && gym[i].Price <= max)
                {
                    Console.WriteLine(gym[i]);
                }
                i++;
            }
        }
Exemple #2
0
        public static void Sort(GYM el) ///////////////Сортировка по цене: от большего к меньшему
        {
            Inventory elem;

            for (int i = 0; i < el.count - 1; i++)
            {
                for (int j = 0; j < el.count - i - 1; j++)
                {
                    if (el.Count_of[j].Price < el.Count_of[j + 1].Price)
                    {
                        elem               = el.Count_of[j];
                        el.Count_of[j]     = el.Count_of[j + 1];
                        el.Count_of[j + 1] = elem;
                    }
                }
            }
        }
Exemple #3
0
        public static void Read_from_file(ref GYM gym)
        {
            string path = "info.txt";

            using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
            {
                int    j        = 0;
                int    price    = 0;
                int    quantity = 0;
                int    space    = 0;
                string form     = "";
                string from_file;
                for (int i = 0; gym.MaxIndex > i; i++)
                {
                    while ((from_file = sr.ReadLine()) != null)
                    {
                        if (j == 0)
                        {
                            price = Convert.ToInt32(from_file);
                        }
                        if (j == 1)
                        {
                            quantity = Convert.ToInt32(from_file);
                        }
                        if (j == 2)
                        {
                            form = from_file;
                        }
                        if (j == 3)
                        {
                            space = Convert.ToInt32(from_file);
                            j     = 0;
                            break;
                        }
                        j++;
                    }
                    gym[i] = new Mats(quantity, price, form, space);
                }
            }
        }