Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Globalization;
  7.  
  8. namespace _08.Mentor_Group
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string input = Console.ReadLine();
  15.             SortedDictionary<string, List<DateTime>> mentorDates = new SortedDictionary<string, List<DateTime>>();
  16.             Dictionary<string, List<string>> mentorComments = new Dictionary<string, List<string>>();
  17.             List<string> inputData = new List<string>();
  18.             string username = string.Empty;
  19.  
  20.             while (input != "end of dates")
  21.             {
  22.                 inputData = input.Split(' ', ',').ToList();
  23.                 username = inputData[0];
  24.                 if (!mentorDates.ContainsKey(username))
  25.                 {
  26.                     mentorDates[username] = new List<DateTime>();
  27.                 }
  28.                 inputData.RemoveAt(0);
  29.                 for (int i = 0; i < inputData.Count; i++)
  30.                 {
  31.                     mentorDates[username].Add(DateTime.ParseExact(inputData[i], "dd/MM/yyyy", CultureInfo.InvariantCulture));
  32.                 }
  33.  
  34.                 input = Console.ReadLine();
  35.             }
  36.  
  37.             input = Console.ReadLine();
  38.  
  39.             while (input != "end of comments")
  40.             {
  41.                 inputData = input.Split('-').ToList();
  42.                 username = inputData[0];
  43.  
  44.                 if (!mentorDates.ContainsKey(username))
  45.                 {
  46.                     input = Console.ReadLine();
  47.                     continue;
  48.                 }
  49.                 if (!mentorComments.ContainsKey(username))
  50.                 {
  51.                     mentorComments[username] = new List<string>();
  52.                 }
  53.                 mentorComments[username].Add(inputData[1]);
  54.  
  55.                 input = Console.ReadLine();
  56.             }
  57.             foreach (var item in mentorDates)
  58.             {
  59.                 if (item.Value.Count != 0)
  60.                 {
  61.                     Console.WriteLine(item.Key);
  62.                     Console.WriteLine("Comments:");
  63.  
  64.                     if (mentorComments.ContainsKey(item.Key))
  65.                     {
  66.                         foreach (var comment in mentorComments[item.Key])
  67.                         {
  68.                             Console.WriteLine($"- {comment}");
  69.                         }
  70.                     }
  71.                 }
  72.                 else
  73.                 {
  74.                     continue;
  75.                 }
  76.                
  77.                 Console.WriteLine("Dates attended:");
  78.                 foreach (var date in mentorDates[item.Key].OrderBy(x => x))
  79.                 {
  80.                     string dateString = date.ToString("dd/MM/yyyy");
  81.                     Console.WriteLine($"-- {dateString}");
  82.                 }
  83.             }
  84.         }
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement