Esempio n. 1
0
        private static void Task6()
        {
            Console.WriteLine("Идет генерация рандомных данных...");

            for (int i = 0; i < rnd.Next(100, 1500); i++)
            {
                switch (rnd.Next(0, 3))
                {
                case 0:
                {
                    Creditor c = new Creditor(); c.GenerateRandData();
                    clients.Add(c);
                    break;
                }

                case 1:
                {
                    Society org = new Society(); org.GenerateRandData();
                    clients.Add(org);
                    break;
                }

                case 2:
                {
                    Investor investor = new Investor();
                    investor.GenerateRandData();
                    clients.Add(investor);
                    break;
                }
                }
            }

start:

            int choice = 0;

            Console.WriteLine("1 - Вывести всех\n2 - Поиск по дате");
            int.TryParse(Console.ReadLine(), out choice);
            switch (choice)
            {
            case 1:
            {
                foreach (Client item in clients)
                {
                    item.PrintInfo();
                }
                Console.WriteLine($"Всего : {phonebooks.Count} клиентов");

                Console.WriteLine("Go to Beginning  - w\nExit - any");
                if (Console.ReadLine()?.ToLower() == "w")
                {
                    goto start;
                }
                break;
            }

            case 2:
            {
                Console.WriteLine("Введите дату : ");
                DateTime date;
                DateTime.TryParse(Console.ReadLine(), out date);

                int counter = 0;
                foreach (Client item in clients)
                {
                    if (item.Search(date))
                    {
                        item.PrintInfo();
                        counter++;
                    }
                }

                Console.WriteLine($"Всего : {counter} клиентов, подходящих по дате");

                Console.WriteLine("Go to Beginning  - w\nExit - any");
                if (Console.ReadLine()?.ToLower() == "w")
                {
                    goto start;
                }
                break;
            }
            }
        }