Example #1
0
        static void Main(string[] args)
        {
            int K, M, R;

            while (true)
            {
                List <Tablets> test = ListCosoleUtils.ReadList();

                K = (int)IOUtils.ReadValueFromConsole <uint>("количество отбираемых планшетов");

                if (K == 0)
                {
                    continue;
                }

                M = (int)IOUtils.ReadValueFromConsole <uint>("минимальный объем памяти");
                if (M == 0)
                {
                    continue;
                }
                R = (int)IOUtils.ReadValueFromConsole <uint>("минимальный рейтинг (1,2,3,4,5)");
                if (R == 0)
                {
                    continue;
                }

                ListClassUtils utils      = new ListClassUtils(test);
                List <Tablets> sortedList = utils.SortTabletsByPrice(utils.SelectTablesByMemoryAndRating(M, R));
                List <Tablets> result     = utils.SelectFirstTablets(sortedList, K);
                ListCosoleUtils.WriteListToConsole(result);

                if (IOUtils.AskQuestion("Сохранить в файл? (y/n)"))
                {
                    ListCosoleUtils.WriteListToFile(result);
                }

                if (!IOUtils.AskQuestion("Продожить? (y/n)"))
                {
                    break;
                }
            }
        }
Example #2
0
        private void StartButtom_Click(object sender, EventArgs e)
        {
            try
            {
                int tabletsCount = int.Parse(this.Col.Text);
                int minMemory    = int.Parse(this.M.Text);
                int minRating    = int.Parse(this.R.Text);
                int minCoast     = int.Parse(this.K.Text);

                ListClassUtils utils      = new ListClassUtils(DGVUtils.DGVToTabletsList(inputGridView));
                List <Tablets> sortedList = utils.SortTabletsByPrice(
                    utils.SelectTablesByMemoryAndRating(minMemory, minRating)
                    );
                List <Tablets> result = utils.SelectFirstTablets(sortedList, tabletsCount);

                DGVUtils.TabletsListToOutputDGV(outputGridView, result);
            }
            catch (Exception)
            {
                MessagesUtils.ShowError("Ошибка");
            }
        }