Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tasks
- {
- public Tasks()
- { }
- private List<string> months = new List<string>();
- private List<List<int>> days = new List<List<int>>();
- private List<List<List<string>>> quantities = new List<List<List<string>>>();
- public List<int> this[string month]
- {
- get => this.days[FindIndex(month)];
- }
- public List<string> this[string month, int day]
- {
- get => this.quantities[FindIndex(month)][FindIndex(month, day)];
- }
- public string this[string month, int day, int index_of_quantity]
- {
- get => this.quantities[FindIndex(month)][FindIndex(month, day)][index_of_quantity];
- }
- public int FindIndex(string month)
- {
- for (int i = 0; i < this.months.Count; i++)
- {
- if (month == this.months[i])
- { return i; }
- }
- return -1;
- }
- public int FindIndex(string month, int day)
- {
- if (is_contain(month))
- {
- for (int i = 0; i < this.days[FindIndex(month)].Count; i++)
- {
- if (day == days[FindIndex(month)][i])
- {
- return i;
- }
- }
- return -1;
- }
- return -1;
- }
- public bool is_contain(string month)
- {
- for (int i = 0; i < this.months.Count; i++)
- {
- if (month == months[i])
- { return true; }
- }
- return false;
- }
- public bool is_contain(string month, int day)
- {
- if (is_contain(month))
- {
- for (int i = 0; i < this.days[FindIndex(month)].Count; i++)
- {
- if (day == this.days[FindIndex(month)][i])
- { return true; }
- }
- return false;
- }
- return false;
- }
- public void Add_Task()
- {
- Console.WriteLine("Введите название месяца: ");
- string month = Console.ReadLine();
- if (FindIndex(month) > -1)
- {
- Console.WriteLine("Введите число: ");
- int day = Console.Read();
- if (FindIndex(month, day) > -1)
- {
- Console.WriteLine("Введите количество добавляемых дел на число: ");
- int count = Console.Read();
- for (int i = 0; i < count; i++)
- {
- string Quantity = Console.ReadLine();
- this[month, day].Add(Quantity);
- }
- }
- else
- {
- this[month].Add(day);
- this.quantities[FindIndex(month)].Add(new List<string>());
- Console.WriteLine("Введите количество добавляемых дел на число: ");
- int count = Console.Read();
- for (int i = 0; i < count; i++)
- {
- string Quantity = Console.ReadLine();
- this[month, day].Add(Quantity);
- }
- }
- }
- else
- {
- this.months.Add(month);
- Console.WriteLine("Введите число: ");
- int day = Console.Read();
- this[month].Add(day);
- this.quantities[FindIndex(month)].Add(new List<string>());
- Console.WriteLine("Введите количество добавляемых дел на число: ");
- int count = Console.Read();
- for (int i = 0; i < count; i++)
- {
- string Quantity = Console.ReadLine();
- this[month, day].Add(Quantity);
- }
- }
- }
- public void Get_Tasks(string month, int day)
- {
- if (is_contain(month, day))
- {
- Console.WriteLine($"Дела на {day} число {month}я: ");
- for (int i = 0; i < this[month, day].Count; i++)
- {
- Console.WriteLine((i).ToString() + this[month, day][i] + ".");
- }
- }
- else
- {
- Console.WriteLine("Ошибка! Дела на заданное число не обнаружены! Желаете добавить новые дела?");
- string answer = Console.ReadLine();
- if (answer == "Да" || answer == "да" || answer == "ДА")
- {
- Add_Task();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement