Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- namespace _08_MentorGroup
- {
- class MentorGroup
- {
- static void Main(string[] args)
- {
- Dictionary<string, Mentor> mentors = new Dictionary<string, Mentor>();
- while (true)
- {
- string[] input = Console.ReadLine()
- .Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (input[0] == "end" && input[1] == "of" && input[2] == "dates")
- {
- break;
- }
- string name = input[0];
- if (!mentors.ContainsKey(name))
- {
- mentors.Add(name, new Mentor());
- }
- for (int i = 1; i < input.Length; i++)
- {
- mentors[name].Attendances.Add(DateTime.ParseExact(input[i], "dd/MM/yyyy", DateTimeFormatInfo.InvariantInfo));
- }
- }
- while (true)
- {
- string[] input = Console.ReadLine()
- .Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
- if (input[0] == "end of comments")
- {
- break;
- }
- string name = input[0];
- if (mentors.ContainsKey(name))
- {
- mentors[name].Comments.Add(input[1]);
- }
- }
- foreach (var mentor in mentors.OrderBy(x => x.Key))
- {
- Console.WriteLine(mentor.Key);
- Console.WriteLine("Comments:");
- foreach (string comment in mentor.Value.Comments)
- {
- Console.WriteLine($"- {comment}");
- }
- Console.WriteLine("Dates attended:");
- foreach (DateTime date in mentor.Value.Attendances.OrderBy(x => x))
- {
- Console.WriteLine($"-- {date:dd/MM/yyyy}");
- }
- }
- }
- }
- class Mentor
- {
- public List<string> Comments;
- public List<DateTime> Attendances;
- public Mentor()
- {
- Comments = new List<string>();
- Attendances = new List<DateTime>();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment