示例#1
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Напишите дату откуда начнется отчет");

                Console.WriteLine("Напишите месяц от 1 до 12");
                int month = Convert.ToInt32(Console.ReadLine());
                while (month < 1 || month > 12)
                {
                    Console.WriteLine("Напишите месяц от 1 до 12");
                    month = Convert.ToInt32(Console.ReadLine());
                }

                Console.WriteLine("Напишите день с 1 до 30");
                int day = Convert.ToInt32(Console.ReadLine());
                while (day < 1 || day > 30)
                {
                    Console.WriteLine("Напишите день с 1 до 30");
                    day = Convert.ToInt32(Console.ReadLine());
                }

                string date = $"{nToString(day)}.{nToString(month)}";

                DateWork dateWork = new DateWork(day, month, date);

                Console.WriteLine($"Напишите день каторый будет добавлен к дате {date}");
                int index = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(dateWork[index]);
            }
            catch
            {
                Console.WriteLine("Значение должно быть числом");
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Write the date where index starts from");

                Console.WriteLine("Write a month, from 1 to 12");
                int month = Convert.ToInt32(Console.ReadLine());
                while (month < 1 || month > 12)
                {
                    Console.WriteLine("Write a month, from 1 to 12");
                    month = Convert.ToInt32(Console.ReadLine());
                }

                Console.WriteLine("Write a day, from 1 to 30");
                int day = Convert.ToInt32(Console.ReadLine());
                while (day < 1 || day > 30)
                {
                    Console.WriteLine("Write a day, from 1 to 30");
                    day = Convert.ToInt32(Console.ReadLine());
                }

                string date = $"{nToString(day)}.{nToString(month)}";

                DateWork dateWork = new DateWork(day, month, date);

                Console.WriteLine($"Write day that will add to {date}");
                int index = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(dateWork[index]);
            }
            catch
            {
                Console.WriteLine("Value has to be an integer");
            }
        }